Reputation: 225
I have recently upgraded my application to log4j2.13.3. Below is my log4j properties file:
appenders=AchLog,AchLog1
appender.AchLog.type = Console
appender.AchLog.name = AchLog
appender.AchLog.target = SYSTEM_OUT
appender.AchLog.layout.type = PatternLayout
appender.AchLog.layout.pattern = %d{DEFAULT} (%c{1} %m%n
appender.AchLog1.type = RollingFile
appender.AchLog1.name = AchLog1
appender.AchLog1.fileName = /home/logs/ach_new.log
appender.AchLog1.filePattern = /home/logs/ach_new.log.%d{yyyy-MM-dd}
appender.AchLog1.layout.type = PatternLayout
appender.AchLog1.layout.pattern = %d{DEFAULT} (%c{1} %m%n
appender.AchLog1.policies.type = Policies
appender.AchLog1.policies.time.type = TimeBasedTriggeringPolicy
appender.AchLog1.policies.time.interval = 1
loggers=AchLog1
logger.AchLog1.name=com.test.ach
logger.AchLog1.level = debug
logger.AchLog1.additivity = false
logger.AchLog1.appenderRef.AchLog1.ref = AchLog1
rootLogger.level = error
rootLogger.appenderRefs = AchLog
rootLogger.appenderRef.AchLog.ref = AchLog
I am calling an sh script. The script is as follows:
/usr/java/jdk1.8.0_181/bin/java -cp /home/test/lib/commons-logging-1.1.3.jar:/home/test/lib/log4j-jcl-2.13.3.jar:/home/test/lib/commons-logging-api-1.1.jar:/home/test/lib/commons-codec-1.3.jar:/home/test/lib/log4j-api-2.13.3.jar:/home/test/lib/log4j-core-2.13.3.jar:/home/test/lib/achpoint.jar:/home/test/lib/activation-1.1.jar:/home/test/lib/jdom.jar:/home/test/lib/mail-1.4.jar:/home/test/lib/sqljdbc4.jar:/home/test/lib/poi-3.6-20091214.jar:/home/test/lib/commons-email-1.1.jar:/home/test/lib/utransfer-core.jar:/home/test/lib/commons-lang-3.1.jar:/home/test/lib/slf4j-api-1.7.25.jar:/home/test/lib/log4j-slf4j-impl-2.13.0.jar com.test.TestProcessor properties/test.properties
I am getting the following error while invoking this sh file. Please find below the error.
Exception in thread "main" org.apache.logging.log4j.core.config.ConfigurationException: No name attribute provided for Appender AchLog
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.createAppender(PropertiesConfigurationBuilder.java:212)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.build(PropertiesConfigurationBuilder.java:151)
The error says there is no name property for appender AchLog. But I have specified it in the properties file. Can someone please help me find the issue.
Upvotes: 0
Views: 3344
Reputation: 11
This answer may come a bit late - I faced a similar issue and fixed it this way:
there: appender.AchLog.name = AchLog
set: appender.AchLog.name = AchLogAppender
and
there: rootLogger.appenderRef.AchLog.ref = AchLog
set: rootLogger.appenderRef.AchLog.ref = AchLogAppender
This should resolve the problem.
Upvotes: 1