How can I make log4j reopen log files periodically (logrotate) - log4j

My sysadmin has been "encouraging" me to fix our web application logs to play nicely with logrotate. The problem is that after logrotate works on a file the application stops logging. Is there a way to configure log4j to reopen log files after this happens?
This comment explains the general problem but doesn't provide a solution for log4j: https://stackoverflow.com/a/6514233/201748

I have still to test it, but the copytruncate option of logrotate should do.

Related

wildfly 20 doesn't log with log4j. Which factors Can be involved for that?

I have two environment development(local) and other QA environment, In the last is a cluster with two nodes.
The problem came with the deploy in QA environment I can't see the log in the server, but locally print console logging without problem.
I'm sure that module structure is the same in both environments, and my configure is in the classpath with xml file.
Which aspect can influence in this difference?
Local print logging console server and QA enviroment dont do it.
I was able to solve this, I checked the server in the development environment, it's a domain configuration and for this reason it did not show the application log in the user wizard, due to application conditions only the applications write to the .log file, at start I was not allowed to check this domain log directory, but after I check this by command line my app log file is right there
I'll hope to help someone else

Turning debug log on/off Weblogic Server

How do i turn off debug logging in Weblogic 12c? I see a weblogic.log file in /tmp folder on my Linux server which is of around 3gb already.
I searched for the debug.properties file but could not find it. Please help.
Go to your AdminServer and check your ManagedServers -> Debug tab to see which debug flags are enabled.
You can disable it, save and activate your changes. After that check your logs to see if it works.

Logback stops logging on file change

Wrote a small test and found that when logging to a file and opening that file in vi, editing and then saving it - Logback stops writing to that file.
No apparent errors in the process that is writing the logs. It keeps running but no logs are appended to the file.
Is anyone familiar with this? Tried running the same against log4j - and it appears to continue writing the logs. I recall reading in the past the log4j also had such a shortcoming but couldn't reproduce.
Please advise.

Mule Logs not showing

I'm trying to launch a Mule application I have written, but I cant seem to get the logs to show up when I run it from the console. When I look at the log file, I see the Mule loading process (assuming I am using the app not the service mode) but then the log goes blank. Note that the log is visible when I'm using Mule Eclipse IDE.
Sounds like your app logging configuration overrides the global one, but is also not doing what you expect. Add -M-Dlog4j.debug switch to the Mule command line to see where rogue log4j config file might be coming from.
To properly log Mule messages into a log file, you should have a category definition in your log4j.properties and refer to that in your Mule flow as:
<logger level="INFO" category="your_custom_category" message="#[payload]"/>
Try to restart the entire machine. It sounds like an Eclipse problem not a problem with your program.
May be you have not properly placed the properties file and jar file.
Place
"log4j.properties" in "WEB-INF/classes"
and copy
log4jx.y.z.jar to "WEB-INF/lib".

log4net - Missing logs

We're using log4net in a number of our services. Most of the time it works flawlessly. However, we'll occasionally see log4net "freezes" for a period of time before continuing to work normally. For example, the logs below shows that log4net was "frozen" for over 4 hours. We know this application is verbose, so we expect to see logs written every second.
2010-11-04 04:02:09,393 DEBUG Some message...
2010-11-04 08:48:07,114 DEBUG Some other message...
Another problem we'll occasionally see is that entire log files get deleted. We have log4net configured to roll over by date. Sometimes we'll see that an entire weeks worth of logs go missing. Is log4net mistakenly deleting these logs files? We do not have log4net configured to keep a number of logs.
Has anyone encountered this before?
I have not seen this, but remember that Log4net is designed to continue even if it can not log its information - See this FAQ Article
If anything locks the log file (eg Backup/AntiVirus) then you will get missing information.
You could trying running DebugView to see if any such warning appears when the logging fails or perhaps configure log4net to keep its own logs (see another FAQ Article )

Resources