log4j

How can I access the configured Log4J appenders at runtime?

I want to configure an appender at startup and then dynamically add and remove it from various loggers on demand. I'd prefer to have log4j configure this appender itself, and just grab a reference to it when needed. If that's not possible, I'll have to instantiate the appender myself and hold onto it. ...

Warbler config.java_classes and log4j.properties

I'm packaging up a rails app with warbler and I want app specific logging. I've added the log4j and commons-loggin jar to the WEB-INF/lib directory, and I want to add log4j.properties to the WEB-INF/classes directory. The problem is, I also want environment specific logging, so my staging/production use different properties (ie. INFO i...

Log4J - SiftingAppender-like functionality

I work in a project that uses Log4J. One of the requirement is to create a separate log file for each thread; this itself was a odd issue, somewhat sorted by creating a new FileAppender on the fly and attaching it to the Logger instance. Logger logger = Logger.getLogger(<thread dependent string>); FileAppender appender = new FileAppende...

How do I configure log4j to start with some text and end with some text?

I'd like to make a log4j output file that is XML and give it a root element. Hence, I'd like it to start with a tag and end with a tag. What do I put in my log4j.xml to make this happen? Right now, all I have is this: <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="logs/file.log" /> <...

Log4J in AS/400

Hi, I am looking for a logging mechanism in AS/400 similar to log4j. I am thinking of writing a wrapper to the log4j in AS/400. Can someone please let me know if there is such a tool present already? Thanks, Sam ...

Reinitialize log4j on web app deployment using Log4jConfigListener

Hello, I have setup Log4jConfigListener in my web.xml and it works fine, however, if I redeploy the web app without restarting the server then log4j shuts down and does not reinitialize. If I remove the Log4jConfigListener from my web.xml then everything works fine. I am using JBoss 4.2.3-GA as the app server. I notice that when I am...

How to set javax logger handle to be refactor sensitive

Someone might yell at me to read the faqqing faq, but I'm in a hurry ... Does anyone have a way to make javax or log4j logger refactor-sensitive? Say, that currently utils.Something has the logger handle: final static private Logger logger = Logger.getLogger(Something.class.getName()); And logging.properties has .level = warning ut...

log4j and the thread context classloader

I'm a newbie to Java and just starting to figure out the concept of class loaders. Right now I am having some issues with log4j regarding its use of the thread context classloader. I'm getting the following errors: A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable. The class "org.apa...

Usage of log4J levels

What is the best practice in using log4j levels while coding. I mean when do we use INFO logging, when do we use DEBUG logging / ERROR logging etc. ...

red5 v0.9: how can i log information to log file?

Hi. I'm reading this tutorial on how to build my project project using eclipse with the red5 eclipse plugin. the problem is that this tutorial is for version 0.6 and i have version 0.9. the tutorial is at: http://www.actionscript.org/resources/articles/615/1/Getting-started-with-red5-server/Page1.html On page 2 that tutorial explains a...

switch from log4j to logback

I have this code with log4j, I don't use any kind of configuration files static Logger logger = Logger.getLogger(Application.class); ... Appender ap = new NTEventLogAppender(); SimpleLayout layout = new SimpleLayout(); Appender fp = null; try { fp = new FileAppender(layout, "output.txt"); } catch (IOException e) { ...

Can you make the Tomcat 6 stdout.log file behave like a log4j DailyRollingFileAppender?

We are using the Windows installation of Tomcat 6. By default, the log4j output for our app goes to the ${catalina.base}/logs/stdout_.log file. This log file only rolls over when we restart Tomcat, and the file name always includes the date. I would prefer it to behave like a DailyRollingFileAppender, where it renames the file when it...

Log4j: rotate the log file even if the file has not changed

i am trying to rotate the log file everyday by using the DailyRollingFileAppender, but i have a problem: the log files are not updated everyday, so it doesn't get rotate when there is no new stuff in it. is there a way in the log4j.properties that i can set it so that log4j rotate the log file everyday even if the file has no changes? ...

slf4j with log4j. Get logger to reset/restart

I am trying to switch System.out on a button action, which works but the logger is still writing to the old PrintStream. import org.slf4j.Logger; import org.slf4j.LoggerFactory; private final static Logger logger = LoggerFactory.getLogger(ActionButtons.class); PrintStream mStartingOut = System.out; public void switchOut() { if (S...

log4j console appender and log file size

I am using Jboss 4.0.2 in Solaris to run a webapp. JBoss is configured to use the factory default log4j.xml file, and this has a ConsoleAppender. I am redirecting stdout of jboss java process to a file. Something interesting happens when I try to cleanup this file - jboss.out. This is where I start. $ ls -alhrt jboss.out -rw-r--r-- ...

Controlling hibernate logging

I got an application running in a jboss container using hibernate. However I'm having trouble with the logging that hibernate is doing. I get these startup messages when Hibernate initialises: 2010-01-08 17:23:42,017 INFO [Configuration:1403] - Configuration resource: /hibernate.cfg.xml 2010-01-08 17:23:42,070 INFO [Configuration:1541...

making server.log append=true

How do I make the log server\\log\serve.log to be appended. i.e. whenver I restart JBoss it should not override the content of the log but continue from the end of it? ...

How to sanitize log messages in Log4j to save them in database

Hello, I'm trying to save log messages to a central database. In order to do this, I configured the following Appender in log4j's xml configuration: <appender name="DB" class="org.apache.log4j.jdbc.JDBCAppender"> <param name="URL" value="jdbc:postgresql://localhost/logging_test" /> <param name="user" value="test...

Init log4j in Weblogic, outside of ear

I can't imagine that my question is so specific to my case, but I did not see any similar questions asked here so far. I would like to be able to specify a log4g.properties file outside of my .ear packaging so that it is easier to alter the logging levels without repackaging the ear. Actually, the most pressing motivation for doing it l...

Configuring multiple log files in log4j while using categories

Here's what I'm trying to do: I want 2 log files: The first logs INFO level and up for all parts of the applications but also logs DEBUG and up for some packages. The second only logs ERROR and up across all packages. I'm sure this is probably trivial but I can't quite figure it out. Here is the configuration file I am currently using: ...