Logback stops logging on file change - log4j

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.

Related

CouchDB local.ini log setting getting overwritten

We have CouchDB 1.5.0 installed and running successfully on a Windows 2008 server. Everything has been working fine for several months, but lately it's started crashing with little information in the logs.
I found local.ini and changed the [log] setting from error to debug, then restarted the service. Everything seemed to work fine, except the setting in local.ini automatically reverted back to error. I downloaded and ran Process Monitor and determined that erl.exe is the guilty party for updating the .ini file.
I even tried removing the [log] block entirely from local.ini to try to grab the default value. When I do this, the erl.exe process comes back through and adds back the [log] block, with the log level set to error.
Am I missing something? Obviously the purpose of local.ini is to override default values. I've seen nothing that indicates why some settings, like the log level, cannot be changed. Process Monitor tells me that the only .ini files being accessed are default.ini and local.ini, so I think I can rule out an extraneous .ini file somewhere that's mucking up the settings.
I'm really at a loss for how to debug our crash if I can't even get more logging info out of the server.
Can you try using Configuration page in Futon? It should do the right thing™.

Log4j sorting logs

I am running one jar on unix machine and takes output of it on windows machine program using JSCH. So, i am creating log file on unix machine this will be detailed log file of jar present on unix.So, here i want to print some restricted output on unix console and take it on my windows application after executing the JAR file and all other info will go into detailed log file.So how i will print restricted output on console using log4j? what i need to do to achieve this? can anybody gives example of this?
You have to configure 2 different "appenders": a ConsoleAppender and a FileAppender, then you can direct output to one of them or both. To select which appender will receive a log item you can discriminate on logging priority (for example console could receive only ERROR and FATAL items, the log file could receive everything) and/or the class or package producing that log item. The log4j intro documentation page explains how to make this configuration.

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

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.

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