log4j

How do you get log4j to roll files based on date and size?

So log4j comes with two existing log rollers: RollingFileAppender, and DailyRollingFileAppender. Has anyone heard of an appender that does both of what the former do? I need an appender that will roll log files based on filesize, but also append the current date to it. I've been thinking about creating my own appender, but if there is ...

Display only selected Log4j debug statements

Is it possible to display only those statements in console, which are having certain words. For eq: logger.debug ( "java: hello " ); logger.debug ( "groovy: hello " ); logger.debug ( "ruby: hello " ); Now, by doing some configuration or whatever, all statements which are starting with groovy: should display. ...

How to log on JBoss console

I'm experimenting with Netbeans and JBoss and I'd like to print stuff on JBoss console from my code. Can I use log4j for that? ...

Is there a Log4J Layout/Formatter that prunes Stack Traces for exceptions?

I'm looking for a Log4J Layout/Formatter that helps me prune stack-traces in exceptions a little better than the defaults. That the stack-execution is somewhere below main() is quite obvious and unnecessary for me to know, and that the exception occurred deeply within some other library is really nothing I can do too much about. What I ...

How do I properly Log4j, closing all Appenders and, therefore, files

My servlet-based web-app sometimes fails to close Log4j log files when redeployed, leaking to file descriptor leakage and occassionally leading to servlet-contained dying from 'too many open files'. I have a ContextListener, what should I put into its contextDestroyed() to tell log4j to shut down and release all resources? Quick skim o...

Have you seen an appender that would log to separate files based on NDC in Log4j?

We have only a very small number of customers (fewer than 50) and we would like each one to have its own separate log file into which all of its server side logging info goes. I know you could use NDC and filters to direct log statements to different files using the standard appenders in Log4j but that would require quite a bit more setu...

How can I convert a log4j timestamp to milliseconds in Perl?

The log4j logs I have contain timestamps in the following format: 2009-05-10 00:48:41,905 I need to convert it in perl to millseconds since epoch, which in this case would be 124189673005, using the following gawk function. How do I do it in perl? I have little or no experience in perl, so appreciate if someone can post an entire sc...

Error in velocity and log4J

Hello, I built a webapp that works perfectly fine in my localhost (tomcat). But when I tried to deploy, velocity crashes in init(), leaving me with this strange stack trace here (sorry for the size): ERROR [main] (VelocityConfigurator.java:62) - Error initializing Velocity! org.apache.velocity.exception.VelocityException: Failed to i...

Why does my Jnlp program not working with log4j ?

Hello there. I have the following problem: I've deployed in Tomcat a JNLP and an executable JAR files. JNLP file should automatically download the JAR file and execute it. The JAR file is signed and verified. This is done (the downloading part). But when to execute the JAR main class (specified in the JNLP file), a problem occurs: A part...

How to send java.util.logging to log4j?

I have an existing application which does all of its logging against log4j. We use a number of other libraries that either also use log4j, or log against Commons Logging, which ends up using log4j under the covers in our environment. One of our dependencies even logs against slf4j, which also works fine since it eventually delegates to l...

Log4j Properties in a Custom Place

I'm using Apache Commons Logging and SLF4J with log4j, but I also want to use the log4j.properties in a custom place like conf/log4.properties. Here is the problem: If i use PropertyConfigurator.configure("conf/log4j.properties"); then my app is tied to log4j and defets the purpose of having ACL and SLF4J. What is the best way to ...

Where do I configure log4j in a JUnit test class?

Looking at the last JUnit test case I wrote, I called log4j's BasicConfigurator.configure() method inside the class constructor. That worked fine for running just that single class from Eclipse's "run as JUnit test case" command. But I realize it's incorrect: I'm pretty sure our main test suite runs all of these classes from one proces...

How do i configure log4j using log4j.xml to append to different log files based on class name?

Hi I want to set up log4j so that all log meessages produced from classes under package com.foo.bar go to bar.log, and all the log meessages produced from classes under package com.bar.blatz go to blatz.log. How do I do this _using_log4j.xml? I know its possible using property files, but how do I do it using the XML configuration? ...

structured/combined logging with Log4J

Hi fellow geeks, I hope you can help me. I have a web service that needs to log transactions. Since there are many hits, the log statements appears disjoint/fragmented in the log file. I've considered passing a StringBuilder instance through-out the layers and appending the statements to this instance, then I log its contents once at t...

Enable Logging Log4j for certain users

Hi, In the log4j.properties file I've set the Level to ERROR. For certain users I need to set Level to DEBUG. I was able to change the Logging Level at run time; but this will be enabled for all the users accessing the application at the same time. Is there any other method by which we can enable logging for selected users? Any help will...

Use MaxBackupIndex in DailyRollingFileAppender -log4j

Hi, Can someone please tell me how to use MaxBackupIndex in DailyRollingFileAppender.I know that the RollingFileAppender supports a maxBackupIndex property, but is there any workarounds for using MaxBackupIndex in DailyRollingFileAppender? ...

Log4j Question

I want to capture the log4j logging comments in the following way. Is it possible ? If so then how should my log4j.properties look like ?? My Message : 2009-05-22 17:07:28 Thanks Rink ...

Logging in Java and in general: Best Practices?

Hi Everyone! Sometimes when i see my logging code i wonder if i do it right. There might be no definitive answer to that, but i've folling concerns: Library Classes: I have several library classes wich might log some INFO messages. Fatal Errors are reported as exceptions. Currently i have a static logger instance in my classes with the...

log4j category

I have the following on my log4j.properties log4j.rootLogger = debug, stdout, fileLog log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.fileLog = org.apache.log4j.RollingFileAppender log4j.appender.fileLog.File = C:/logs/services.log log4j.appender.fileLog.MaxFileSize = 256MB log4j.appender.fileLog.MaxBackupIndex...

Tomcat 6 and log4j application logging produce no output

I'm trying to get log4j application (webapp) logging working in a Tomcat 6 app. I have log4j-1.2.15.jar in my WEB-INF directory, log4j.dtd and log4j.xml in WEB-INF/classes. My log4j.xml looks like: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" > <log4j:configuration> <appender name="massAppende...