File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes A Log4j Stumper, can't get logs in the right place. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "A Log4j Stumper, can Watch "A Log4j Stumper, can New topic

A Log4j Stumper, can't get logs in the right place.

Paul Duer
Ranch Hand

Joined: Oct 10, 2002
Posts: 98
Hi guys, I want to log a process into a special log file. I setup a special category for it and I initalize it correctly. But I don't want the log statments to print in the stdout console log.
How do I do that? Here's my current log4j properties file:
#### Setup the Categories
# This is where we setup our debug levels.
# All appenders must be in this list to be initialized correctly.
# You MUST have the ', appender' for this to work!
# Debug logging per class
#### Setup the Appenders
# To add an appender, simply copy the soap section. Change all places you see 'soap' to whatever
# you want the appender to be named. Change the end of the 'File' line to the appropriate log location/name.
# stdout log - Use this appender if you want to use log4j to log to the console.
log4j.appender.stdout.layout.ConversionPattern=[%d{dd MMM yyyy HH:mm:ss,SSS}] %-5p %c{1} %x - %m%n
# soap log
log4j.appender.soap.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss.SSS} %p - %m%n
Vikas Varma

Joined: Aug 21, 2002
Posts: 23

Change the log4j property to
Margit Bork

Joined: Mar 03, 2004
Posts: 7
is also a possibility, to avoid logging to a logger up the hieracy
Margit Bork

Joined: Mar 03, 2004
Posts: 7
does i work for you to set the log4j.rootLogger to warn ?
When i try to get a logger that does not make output unles the logger is specified i fail. I mean if i havent specified the logger that i instantiate it get at default loglevel on debug - and i dont want that.
I hope it is possible to define a hieracy of loggers mirroring my class hieracy, so that i dont have to make a specific configuration for each class's logger (I want each class to have its own logger to be able to pinpoint logging in the production environment )
Any experience with this ??
I agree. Here's the link:
subject: A Log4j Stumper, can't get logs in the right place.
It's not a secret anymore!