Targets not configured for logger. Linux + MONO - nlog

I'm using NLOG with Linux + MONO ASP.NET WebService and I'm not able to log two different file.
ASMX file have two different methos and I would like to log in separate logging file
This is Nlog.config
...
<targets async="true">
<target name="sendMail" xsi:type="File" fileName="${logDirectory}/${shortdate}_sendMail_${level}.log"
layout="${time} ${uppercase:${level}} ${message}" />
<target name="checkMail" xsi:type="File" fileName="${logDirectory}/${shortdate}_checkMail_${level}.log"
layout="${time} ${uppercase:${level}} ${message}" />
</targets>
<rules>
<logger name="sendMail" minlevel="Debug" writeTo="sendMail" />
<logger name="checkMail" minlevel="Debug" writeTo="checkMail" />
</rules>
</nlog>
This is the log file:
2020-04-20 01:42:39.6781 Debug LogFactory Flush with timeout=15 secs
2020-04-20 01:42:39.6907 Debug FileTarget(Name=sendMail_wrapped): Process file '/var/log/wsMail/2020-04-20_sendMail_Info.log' on startup
2020-04-20 01:42:39.6907 Debug FileTarget(Name=checkMail_wrapped): Process file '/var/log/wsMail/2020-04-20_checkMail_Info.log' on startup
2020-04-20 01:42:39.7058 Debug Creating file appender: /var/log/wsMail/2020-04-20_checkMail_Info.log
2020-04-20 01:42:39.7058 Debug Creating file appender: /var/log/wsMail/2020-04-20_sendMail_Info.log
2020-04-20 01:42:39.7442 Debug Flush completed
2020-04-20 01:42:39.7442 Info Shutdown() called. Logger closing...
2020-04-20 01:42:39.7442 Info Closing old configuration.
2020-04-20 01:42:39.7442 Debug LogFactory Flush with timeout=15 secs
2020-04-20 01:42:39.7442 Debug Flush completed
2020-04-20 01:42:39.7442 Debug Closing logging configuration...
2020-04-20 01:42:39.7490 Debug Closing target 'AsyncWrapper Target[sendMail](File Target[sendMail_wrapped])'.
2020-04-20 01:42:39.7533 Debug Closed target 'AsyncWrapper Target[sendMail](File Target[sendMail_wrapped])'.
2020-04-20 01:42:39.7533 Debug Closing target 'File Target[sendMail_wrapped]'.
2020-04-20 01:42:39.7585 Debug FileAppender Closing Invalidate - /var/log/wsMail/2020-04-20_sendMail_Info.log
2020-04-20 01:42:39.7620 Debug Closed target 'File Target[sendMail_wrapped]'.
2020-04-20 01:42:39.7620 Debug Closing target 'AsyncWrapper Target[checkMail](File Target[checkMail_wrapped])'.
2020-04-20 01:42:39.7620 Debug Closed target 'AsyncWrapper Target[checkMail](File Target[checkMail_wrapped])'.
2020-04-20 01:42:39.7639 Debug Closing target 'File Target[checkMail_wrapped]'.
2020-04-20 01:42:39.7639 Debug FileAppender Closing Invalidate - /var/log/wsMail/2020-04-20_checkMail_Info.log
2020-04-20 01:42:39.7639 Debug Closed target 'File Target[checkMail_wrapped]'.
2020-04-20 01:42:39.7639 Debug Finished closing logging configuration.
2020-04-20 01:42:39.7639 Debug Stopping file watching for path '/var/www/wsMail' filter 'NLog.config'
2020-04-20 01:42:39.7775 Debug Targets not configured for logger: sendMail
2020-04-20 01:42:39.7775 Debug Targets not configured for logger: checkMail
2020-04-20 01:42:39.7775 Info Logger has been closed down.
This is the code in VS2019
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<ToolboxItem(False)>
Public Class wsMail
Inherits System.Web.Services.WebService
Public Credentials As AuthHeader
Public smLog As NLog.Logger = LogManager.GetLogger("sendMail")
Public cmLog As NLog.Logger = LogManager.GetLogger("checkMail")
Public messageID As String = Nothing
Public retMsg As String = Nothing
Public retRemoteMsg As String = Nothing
......
cmLog.Error("|" & idCustomer & "|" & remoteIP & "|wrong Password|")
smLog.Debug("- v1.0.1 |" & idCustomer & "|" & remoteIP & "|" & ex.Message & ex.StackTrace & "|")
Any help is appreciated, thanks a lot

Related

log4j-1.2-api bridge ClassNotFoundException:org.apache.log4j.RollingFileAppender

I try to migrate my application from log4j to log4j2. According to official manual I have org.apache.logging.log4j:log4j-1.2-api:2.17.1, org.apache.logging.log4j:log4j-api:2.17.1 and org.apache.logging.log4j:log4j-core:2.17.1 in my maven dependencies. I use log4j.properties file so I enabled compatibility mode (-Dlog4j1.compatibility=true). RollingFileAppender is configured in my log4j.properties file:
log4j.appender.A2=org.apache.log4j.RollingFileAppender
I get following error:
2022-02-16 21:04:20,396 main ERROR Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
According to official manual, RollingFileAppender is a supported component. I had log4j:log4j:1.2.17 dependency before migration to log4j2 and it contains org.apache.log4j.RollingFileAppender class. Unfortunately none of the log4j-1.2-api,log4j-api and log4j-core libraries contain this class. I do not understand why RollingFileAppender is not present in log4j bridge if manual says that RollingFileAppender is supported component. I have found similar question but without a satisfactory answer. How to migrate RollingFileAppender?
UPDATE
Here is my log4j.properties file:
log4j.rootCategory=INFO, A1, A2
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d%m%M %n
log4j.appender.A2.file=C:/projects/test/Log.log
#log4j.appender.A2.layout=org.apache.log4j.PatternLayout
#log4j.appender.A2.layout.ConversionPattern=[%d{dd.MM HH.mm.ss.SSS} %-5p %-20c{1}] : %m%n
#log4j.appender.A2.MaxFileSize=10000KB
#log4j.appender.A2.MaxBackupIndex=3
I added -Dlog4j2.debug=true. There are tons of logs. I chose interesting logs:
TRACE StatusLogger Trying to find [log4j.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader#2437c6dc.
DEBUG StatusLogger Not in a ServletContext environment, thus not loading WebLookup plugin.
DEBUG StatusLogger PluginManager 'Log4j Builder' found 18 plugins
DEBUG StatusLogger Parsing for [root] with value=[INFO, A1, A2].
DEBUG StatusLogger Level token is [INFO].
DEBUG StatusLogger Logger root level set to INFO
DEBUG StatusLogger Parsing appender named "A1".
DEBUG StatusLogger PluginManager 'Converter' found 47 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false
DEBUG StatusLogger Adding appender named [A1] to loggerConfig [].
DEBUG StatusLogger Parsing appender named "A2".
WARN StatusLogger Unable to create File Appender, no file name provided
ERROR StatusLogger Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
DEBUG StatusLogger Appender named [A2] not found.
DEBUG StatusLogger Finished configuring.
The reason configuration fails is explained by the following message:
WARN StatusLogger Unable to create File Appender, no file name provided
This is caused by a compatibility problem between the Log4j 1.x bridge and the original Log4j 1.x: property names must start with a capital letter (cf. LOG4J2-3316). This will be solved in the next release.
Until then, you can use:
log4j.appender.A2.File=C:/projects/test/Log.log
(with a capital F).

NLOG do not logs unhandled exceptions on server

I am experiencing following behavior:
In development (local) there is no problem logging exceptions, all kind works.
When I logged in remote server ( by remote desktop connection ) and open a chrome inside the server and create the exception, there is also no problem, all kind of logging works.
If I use my laptop and Chrome Browser to open the same website that is hosted on the server:
Controller/Action
{
// log record gets created for the following line
logger.Log(LogLevel.Fatal, "Sample informational message");
// log record not created. However this record get created in item 1 and 2 case above
int a = int.Parse("A");
}
Global.asax
protected void Application_Error(object sender, EventArgs e)
{
Logger logger = LogManager.GetCurrentClassLogger();
logger.Fatal(Server.GetLastError());
Server.ClearError();
}
NLog.config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off"
internalLogFile="D:\...\logs\nlog-internal.log">
<!--Define Various Log Targets like files, database or asp.net trace files-->
<targets>
<target name="console" xsi:type="ColoredConsole" layout="${message}" />
<!--Write logs to File where we want to write error logs-->
<target name="file"
archiveFileName="logs/archives/app-log.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="7"
xsi:type="File"
fileName="D:\...\logs\ErrorLogFile.log"
layout="--------------------- ${level} (${longdate}) ${machinename} --------------------
${newline}
${newline}
Additional Info : ${message}${newline}
Exception Type : ${exception:format=Type}${newline}
Exception Message: ${exception:format=Message}${newline}
Stack Trace : ${exception:format=Stack Trace}${newline}
">
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
internalLogLevel="Debug" output:
2018-09-20 19:26:10.4825 Debug ScanAssembly('NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c')
2018-09-20 19:26:10.5275 Debug Search for auto loading files, location: C:\inetpub\wwwroot\Test
2018-09-20 19:26:10.5275 Debug Start auto loading, location: C:\inetpub\wwwroot\Test
2018-09-20 19:26:10.5345 Debug Auto loading done
2018-09-20 19:26:10.5345 Info Message Template Auto Format enabled
2018-09-20 19:26:10.5345 Debug Setting 'UppercaseLayoutRendererWrapper.uppercase' to 'true'
2018-09-20 19:26:10.5345 Debug Setting 'ColoredConsoleTarget.name' to 'console'
2018-09-20 19:26:10.5345 Debug Setting 'ColoredConsoleTarget.layout' to '${message}'
2018-09-20 19:26:10.5345 Info Adding target ColoredConsole Target[console]
2018-09-20 19:26:10.5345 Debug Registered target console: NLog.Targets.ColoredConsoleTarget
2018-09-20 19:26:10.5525 Debug Setting 'UppercaseLayoutRendererWrapper.uppercase' to 'true'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.name' to 'file'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveFileName' to 'logs/archives/app-log.{#}.txt'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveEvery' to 'Day'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveNumbering' to 'Rolling'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.maxArchiveFiles' to '7'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.fileName' to 'C:\temp\logs\ErrorLogFile.log'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.layout' to '--------------------- ${level} (${longdate}) ${machinename} -------------------- ${newline} ${newline} Additional Info : ${message}${newline} Exception Type : ${exception:format=Type}${newline} Exception Message: ${exception:format=Message}${newline} Stack Trace : ${exception:format=Stack Trace}${newline} '
2018-09-20 19:26:10.5795 Debug Setting 'ExceptionLayoutRenderer.format' to 'Type'
2018-09-20 19:26:10.5815 Debug Setting 'ExceptionLayoutRenderer.format' to 'Message'
2018-09-20 19:26:10.5815 Debug Setting 'ExceptionLayoutRenderer.format' to 'Stack Trace'
2018-09-20 19:26:10.5815 Info Adding target File Target[file]
2018-09-20 19:26:10.5815 Debug Registered target file: NLog.Targets.FileTarget
2018-09-20 19:26:10.5815 Info Configured from an XML element in C:\inetpub\wwwroot\Test\NLog.config...
2018-09-20 19:26:10.5815 Debug Unused target checking is started... Rule Count: 1, Target Count: 2
2018-09-20 19:26:10.5815 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: console
2018-09-20 19:26:10.5815 Debug Unused target checking is completed. Total Rule Count: 1, Total Target Count: 2, Unused Target Count: 1
2018-09-20 19:26:10.5815 Debug --- NLog configuration dump ---
2018-09-20 19:26:10.5815 Debug Targets:
2018-09-20 19:26:10.5815 Debug ColoredConsole Target[console]
2018-09-20 19:26:10.5815 Debug File Target[file]
2018-09-20 19:26:10.5815 Debug Rules:
2018-09-20 19:26:10.5815 Debug logNamePattern: (:All) levels: [ Trace Debug Info Warn Error Fatal ] appendTo: [ file ]
2018-09-20 19:26:10.5815 Debug --- End of NLog configuration dump ---
2018-09-20 19:26:10.5815 Info Found 23 configuration items
2018-09-20 19:26:10.6105 Debug Watching path 'C:\inetpub\wwwroot\Test' filter 'NLog.config' for changes.
2018-09-20 19:26:10.6115 Info Configuration initialized.
2018-09-20 19:26:10.6115 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.5.7.7958. Product version: 4.5.7.
2018-09-20 19:26:10.6115 Debug Targets for Data.Repositories.CommonRepository by level:
2018-09-20 19:26:10.6115 Debug Trace => file
2018-09-20 19:26:10.6115 Debug Debug => file
2018-09-20 19:26:10.6115 Debug Info => file
2018-09-20 19:26:10.6115 Debug Warn => file
2018-09-20 19:26:10.6115 Debug Error => file
2018-09-20 19:26:10.6115 Debug Fatal => file
2018-09-20 19:26:10.6405 Debug Targets for Emailer.EmailManager by level:
2018-09-20 19:26:10.6405 Debug Trace => file
2018-09-20 19:26:10.6405 Debug Debug => file
2018-09-20 19:26:10.6405 Debug Info => file
2018-09-20 19:26:10.6405 Debug Warn => file
2018-09-20 19:26:10.6405 Debug Error => file
2018-09-20 19:26:10.6405 Debug Fatal => file
2018-09-20 19:26:10.6435 Debug Targets for UI.Controllers.BaseController by level:
2018-09-20 19:26:10.6435 Debug Trace => file
2018-09-20 19:26:10.6435 Debug Debug => file
2018-09-20 19:26:10.6435 Debug Info => file
2018-09-20 19:26:10.6435 Debug Warn => file
2018-09-20 19:26:10.6435 Debug Error => file
2018-09-20 19:26:10.6435 Debug Fatal => file
2018-09-20 19:26:10.7735 Debug FileTarget(Name=file): Process file 'C:\temp\logs\ErrorLogFile.log' on startup
2018-09-20 19:26:10.7735 Debug Creating file appender: C:\temp\logs\ErrorLogFile.log
MVC 5 project. .Net 4.5.2. NLog version 4.5.7
I also use SignalR in the project. The log folder has modify rights for IIS_IUSRS.
Any help appreciated.
In my case, It turned out Application_Error do not get called in server environment. implementing OnException method and logging in the method solved the issue.
I post my answer https://github.com/NLog/NLog/issues/2924

JBoss AS 6.1.0.Final suffers from overdone debug logging created by pdfox (PDFStreamEngine)

When I'm performing this line in my class:
pages.get(i).convertToImage(IMAGE_TYPE, RESOLUTION);
... I receive a lot of the following messages:
2014-06-11 17:01:42,476 DEBUG [org.apache.pdfbox.util.PDFStreamEngine] (DefaultQuartzScheduler_Worker-10) processing substream token: PDFOperator{Tj}
2014-06-11 17:01:42,494 DEBUG [org.apache.pdfbox.util.PDFStreamEngine] (DefaultQuartzScheduler_Worker-10) processing substream token: PDFOperator{ET}
2014-06-11 17:01:42,494 DEBUG [org.apache.pdfbox.util.PDFStreamEngine] (DefaultQuartzScheduler_Worker-10) processing substream token: PDFOperator{Q}
Nevertheless, the root logger in my jboss-logging.xml has been put to INFO. When I explicitly put this in my XML config:
<logger category="org.apache.pdfbox.util.PDFStreamEngine">
<level name="INFO"/>
</logger>
... it is still putting DEBUG statements in my LOG file.
Any help?

akka, spray, and log4j2 not logging right

I am scaffolding a new application in Akka, Spray, and Log4j2. I have most of the major systems working in "hello world" type mode, but I'm having a hard time getting the logging to work as I want and I can't tell if this is a log4j2 issue, an Akka/Spray issue, or a retarded me issue.
First, my Akka config file
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = DEBUG
log-config-on-start = on
actor{
debug {
receive = on
autoreceive = on
lifecycle = on
fsm = on
event-stream = on
unhandled = on
router-misconfiguration = on
}
}
}
Now, if I comment out the loggers line and run the app in IntelliJ, its perfect in the console. I get everything I want, I get very verbose and helpful logs, I get the config settings, I see the transactions coming in and going out, I'm a very happy person. The problem occurs when I try to pipe it thru Log4j2.
Now the reason I want to do this is in the not too distant future, i'm going to be pumping all logs to a Cassandra cluster for mapreduce work.
So I uncomment the slf4j line in the config file above, add slf4j, log4j2 and log4j2's log4j-slf4j-impl in the classpath and log4j activates, reads the config file, creates the log file, logs to the console the initializing of the appenders and the debug info, and thats it. nothing else comes out. not one blessed thing. nada.
here's my log4j2.xml file
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="DEBUG">
<appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p %c{2} - %m%n" />
</Console>
<RollingRandomAccessFile name="logFileOutput" fileName="logs/wisdomOutput.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<pattern>%d %p %C [%t] %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</appenders>
<loggers>
<!-- if you want to dump different packages to different files, here's where you do it
<logger name="com.onuspride" level="DEBUG" additivity="false">
<appender-ref ref="logFileOutput"/>
</logger>-->
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="logFileOutput"/>
</root>
</loggers>
</configuration>
I don't know if I'm dealing with a bug in log4j2, or if my configuration file is wrong, or what.
Here is my console output when my logging is activated
/usr/lib/jvm/java-7-oracle/bin/java -Didea.launcher.port=7533 -Didea.launcher.bin.path=/home/willie/apps/intellij13/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/home/willie/code/onus/collective/build/production/wisdom:/home/willie/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.10.0/10ec1256a6e875e886fec050edb0669166912d0d/scala-reflect-2.10.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-routing/1.2.0/955690e1d6b0d92f06da4b53a185a0d59615e1c6/spray-routing-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-ast_2.10/3.2.6/e52c46c51f75a7536c3ffedefdbdc331ffaecbdd/json4s-ast_2.10-3.2.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-http/1.2.0/ba24112e069e61224255f6c3cf85727767351fcc/spray-http-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-core_2.10/3.2.6/c89c64b04fec958fc57a271bc741dfde759d8ffc/json4s-core_2.10-3.2.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.thoughtworks.paranamer/paranamer/2.6/52c3c8d8876440d714e23036eb87bcc4244d9aa5/paranamer-2.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-util/1.2.0/efea073f15b79a3f62f1f16b22cfcad9a2119439/spray-util-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-native_2.10/3.2.6/3728a03373e3eac2354ea0cc855fef71fe97d82e/json4s-native_2.10-3.2.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.10.0/fec8066cd2b4f8dc7ff7ba7a8e0a792939d9f9a/scala-compiler-2.10.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.jvnet.mimepull/mimepull/1.9.3/c55096ff89a27e22c2e081371d0570ac19cc6788/mimepull-1.9.3.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.parboiled/parboiled-scala_2.10/1.1.6/bc93b215151f7dc42653f3eb0243b3130a7e1e11/parboiled-scala_2.10-1.1.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.chuusai/shapeless_2.10/1.2.4/2f41ccc19eb4d38ae5ef907ce7469003e0253dc5/shapeless_2.10-1.2.4.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.parboiled/parboiled-core/1.1.6/11bd0c34fc6ac3c3cbf440ab8180cc6422c044e9/parboiled-core-1.1.6.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-httpx/1.2.0/328e8d28cd3fcd7a7aea6467048a17577d427272/spray-httpx-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.scala-lang/scalap/2.10.0/ab42ae21d1fd7311b367fe3d7f33343f2e4bff6b/scalap-2.10.0.jar:/home/willie/code/onus/collective/build/production/inclusive:/home/willie/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.1/905075e6c80f206bbe6cf1e809d2caa69f420c76/commons-lang3-3.1.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework.security/spring-security-web/3.1.4.RELEASE/56d52794df838d0bc3ccbc149a62ea019946f82a/spring-security-web-3.1.4.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.3.0/f5e853a20b60758922453d56f9ae1e64af5cb3da/jackson-annotations-2.3.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.1/5043bfebc3db072ed80fbd362e7caf00e885d8ae/commons-logging-1.1.1.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jdbc/3.0.7.RELEASE/c53d9bf4e6a6a6cf49c7d7630e612042364295a1/spring-jdbc-3.0.7.RELEASE.jar:/home/willie/.m2/repository/org/springframework/social/spring-social-security/1.1.0.M4/spring-social-security-1.1.0.M4.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-webmvc/3.2.3.RELEASE/6d6d1b53c53dbefd0d8c15f2d5c194ced1f8d53c/spring-webmvc-3.2.3.RELEASE.jar:/home/willie/.m2/repository/org/springframework/social/spring-social-web/1.1.0.M4/spring-social-web-1.1.0.M4.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/3.2.3.RELEASE/accdd65db57e79e49f2af037bb76f5a55a580f00/spring-core-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/aopalliance/aopalliance/1.0/235ba8b489512805ac13a8f9ea77a1ca5ebe3e8/aopalliance-1.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework.security/spring-security-core/3.1.4.RELEASE/41af4a10d7e31722bd8ef2c101f60afb6c24e04b/spring-security-core-3.1.4.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar:/home/willie/.m2/repository/org/springframework/social/spring-social-core/1.1.0.M4/spring-social-core-1.1.0.M4.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/3.2.3.RELEASE/a48eb92ef51e0aed7d23dcaa54225b8f24808db4/spring-beans-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/3.2.3.RELEASE/51e4c94a79892c0a2d15c5efda8c5b336ebf5c37/spring-expression-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/3.2.3.RELEASE/833c5e9a60f82209a3f669a5026dfa8de57c1df3/spring-web-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/3.2.3.RELEASE/12ad5920647556704f79cc579d4e133430741c5/spring-context-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/3.2.3.RELEASE/a70bec95e45a29cad126d250699d0ed0fedfe28a/spring-aop-3.2.3.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.springframework/spring-tx/3.0.7.RELEASE/c340bf8606f6bf235bc1277d25315df1abe51c31/spring-tx-3.0.7.RELEASE.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-can/1.2.0/4a3ec8def45e7f567739fe15a6537f57316612bf/spray-can-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/io.spray/spray-io/1.2.0/35c2866c4c7ac7f9b4ee2c06df18075a5bb8c55b/spray-io-1.2.0.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.0-beta9/1dd66e68cccd907880229f9e2de1314bd13ff785/log4j-api-2.0-beta9.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.0-beta9/678861ba1b2e1fccb594bb0ca03114bb05da9695/log4j-core-2.0-beta9.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.3/21d99cee3d3e478255ef9fcc90b571fb2ab074fc/scala-library-2.10.3.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.typesafe/config/1.0.2/a0bca82c39f23f75e3afccd6e12840eeabaea123/config-1.0.2.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.10/2.2.3/3a74ea5a7ec2a23fa22077c4debebf96f015dc73/akka-actor_2.10-2.2.3.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.5/6b262da268f8ad9eff941b25503a9198f0a0ac93/slf4j-api-1.7.5.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-slf4j_2.10/2.2.3/616c79a2d66ebd136bf0a4e5902bcd1e74dd4cb1/akka-slf4j_2.10-2.2.3.jar:/home/willie/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.0-beta9/e970fc3c10144a521d691db4ac38027cc1935b74/log4j-slf4j-impl-2.0-beta9.jar:/home/willie/.gradle/caches/modules-2/files-2.1/com.lmax/disruptor/3.2.0/ac62995678dd4b906e85b26354aa2ebfda130c32/disruptor-3.2.0.jar:/home/willie/apps/intellij13/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain com.onuspride.wisdom.Boot
2014-01-10 17:42:36,673 DEBUG Generated plugins in 0.000064883 seconds
2014-01-10 17:42:36,719 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%-5p %c{2} - %m%n", Configuration(/home/willie/code/onus/collective/build/production/wisdom/log4j2.xml), null, charset="null", alwaysWriteExceptions="null")
2014-01-10 17:42:36,721 DEBUG Generated plugins in 0.000061321 seconds
2014-01-10 17:42:36,727 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%-5p %c{2} - %m%n), null, target="SYSTEM_OUT", name="CONSOLE", follow="null", ignoreExceptions="null")
2014-01-10 17:42:36,729 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C [%t] %m%n", Configuration(/home/willie/code/onus/collective/build/production/wisdom/log4j2.xml), null, charset="null", alwaysWriteExceptions="null")
2014-01-10 17:42:36,732 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy for element TimeBasedTriggeringPolicy with params(interval="null", modulate="null")
2014-01-10 17:42:36,735 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="50 MB")
2014-01-10 17:42:36,743 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy for element Policies with params(Policies={TimeBasedTriggeringPolicy, SizeBasedTriggeringPolicy(size=52428800)})
2014-01-10 17:42:36,748 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(max="20", min="null", fileIndex="null", compressionLevel="null", Configuration(/home/willie/code/onus/collective/build/production/wisdom/log4j2.xml))
2014-01-10 17:42:36,754 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile with params(fileName="logs/wisdomOutput.log", filePattern="logs/${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz", append="null", name="logFileOutput", immediateFlush="null", Policies(CompositeTriggeringPolicy{TimeBasedTriggeringPolicy, SizeBasedTriggeringPolicy(size=52428800)}), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=20)), PatternLayout(%d %p %C [%t] %m%n), null, ignoreExceptions="null", advertise="null", advertiseURI="null", Configuration(/home/willie/code/onus/collective/build/production/wisdom/log4j2.xml))
2014-01-10 17:42:36,763 DEBUG Starting RollingRandomAccessFileManager logs/wisdomOutput.log
2014-01-10 17:42:36,767 DEBUG Generated plugins in 0.000057060 seconds
2014-01-10 17:42:36,772 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(Appenders={CONSOLE, logFileOutput})
2014-01-10 17:42:36,773 DEBUG Generated plugins in 0.000052311 seconds
2014-01-10 17:42:36,777 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="CONSOLE", level="null", null)
2014-01-10 17:42:36,778 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="logFileOutput", level="null", null)
2014-01-10 17:42:36,783 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="null", includeLocation="null", AppenderRef={CONSOLE, logFileOutput}, Properties={}, Configuration(/home/willie/code/onus/collective/build/production/wisdom/log4j2.xml), null)
2014-01-10 17:42:36,787 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(Loggers={root})
2014-01-10 17:42:36,799 DEBUG Reconfiguration completed
2014-01-10 17:42:36,808 DEBUG Using default SystemClock for timestamps
2014-01-10 17:42:36,815 DEBUG property AsyncLogger.WaitStrategy=null
2014-01-10 17:42:36,815 DEBUG disruptor event handler uses SleepingWaitStrategy
2014-01-10 17:42:37,045 DEBUG No AsyncLogger.ExceptionHandler specified
2014-01-10 17:42:37,058 DEBUG Starting AsyncLogger disruptor with ringbuffer size 262144...
I guess my problem is I can't figure out how to channel stdout from Akka, thru log4j2 to be formatted, and then written to a file. For the time being I really don't want to be any more complex than that.
What is wrong with my setup? Why isn't this working?
figure it out. here's my config
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">
<appenders>
<!--<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p %c{2} - %m%n" />
</Console>-->
<RollingRandomAccessFile name="logFileOutput" fileName="logs/wisdomOutput.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<pattern>%d %p %C [%t] %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</appenders>
<loggers>
<!-- if you want to dump different packages to different files, here's where you do it
<logger name="com.onuspride" level="DEBUG" additivity="false">
<appender-ref ref="logFileOutput"/>
</logger>-->
<root level="debug" includeLocation="true">
<!--<appender-ref ref="CONSOLE"/>-->
<appender-ref ref="logFileOutput"/>
</root>
</loggers>
</configuration>
All looks good, I think you just need to set the log level of the root logger (looks like you already found that).
One small thing: in the RollingFile appender PatternLayout you are using %C.
I recommend you use %c (lowercase) instead. %C walks the stack trace to get location info and will give much worse performance. (The log4j2 manual has more details.)

Recursive call to appender error using Log4j2 with Flume

I am using Log4j2 with the Flume appender with the following configuration:
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug" name="ALI" packages="">
<appenders>
<Flume name="eventLogger" suppressExceptions="false" compress="false">
<Agent host="localhost" port="4141"/>
<RFC5424Layout enterpriseNumber="18060" includeMDC="true" appName="com.weather.ali"/>
</Flume>
<RollingFile name="VTECs" fileName="logs/vtecs.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<pattern>[%d{ISO8601}] %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</appenders>
<loggers>
<root level="debug">
<appender-ref ref="eventLogger"/>
</root>
<logger name="VTEC" level="debug">
<appender-ref ref="VTECs"/>
</logger>
</loggers>
</configuration>
This works as expected on a couple nodes, but the remaining nodes produce the following error:
ERROR Recursive call to appender eventLogger
Here is the full output of the Log4j bootstrap:
2013-05-07 09:21:59,033 DEBUG Calling createAgent on class org.apache.logging.log4j.flume.appender.Agent for element Agent with params(host="localhost", port="4141")
2013-05-07 09:21:59,040 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.RFC5424Layout for element RFC5424Layout with params(facility="null", id="null", enterpriseNumber="18060", includeMDC="true", mdcId="null", mdcPrefix="null", eventPrefix="null", newLine="null", newLineEscape="null", appName="com.weather.ali", messageId="null", mdcExcludes="null", mdcIncludes="null", mdcRequired="null", charset="null", exceptionPattern="null", Configuration(MyApp))
2013-05-07 09:22:02,148 DEBUG Generated plugins in 3.106963125 seconds
2013-05-07 09:22:02,156 DEBUG Calling createAppender on class org.apache.logging.log4j.flume.appender.FlumeAppender for element Flume with params(agents={host=localhost port=4141}, properties={}, embedded="null", type="null", dataDir="null", connectTimeout="null", requestTimeout="null", agentRetries="null", maxDelay="null", name="eventLogger", suppressExceptions="false", mdcExcludes="null", mdcIncludes="null", mdcRequired="null", mdcPrefix="null", eventPrefix="null", compress="false", batchSize="null", null, RFC5424Layout(facility=LOCAL0 appName=com.weather.ali defaultId=Audit enterpriseNumber=18060 newLine=false includeMDC=true messageId=null), null)
2013-05-07 09:22:02,159 DEBUG Starting FlumeAvroManager FlumeAvro[localhost:4141]
2013-05-07 09:22:02,552 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={eventLogger})
2013-05-07 09:22:06,774 DEBUG Generated plugins in 4.221008626 seconds
2013-05-07 09:22:06,776 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="eventLogger", level="null", null)
2013-05-07 09:22:06,778 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="debug", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef#55ed34f1}, properties={}, Configuration(MyApp), null)
2013-05-07 09:22:06,779 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={root})
2013-05-07 09:22:06,779 DEBUG Shutting down OutputStreamManager SYSTEM_OUT
2013-05-07 09:22:06,779 DEBUG Reconfiguration completed
2013-05-07 09:22:07,237 ERROR Recursive call to appender eventLogger
So two questions:
Why would this work on some nodes and not on others?
I have looked at the code where this error is generated, and it appears to get called whenever the appender code gets called more than once. I see no reason why this should happen. Can someone explain this to me?
This turned out (not surprisingly) to be a flume configuration issue on the affected nodes. The Flume agents on those nodes were not starting properly, and this resulted in the fairly cryptic recursion error.
FYI, for others chasing similar log4j recursion warnings:
https://issues.apache.org/jira/browse/LOG4J2-2738

Resources