log4j duplicating appender entries

G

George Jempty

I'm totally new to log4j. I'm trying to incorporate logging into a
pile of crap -- er, I mean "application" -- I've inherited. I'm doing
this without the benefit of a configuration file, at least on my first
attempt, until I get to understanding log4j better.

The following code of mine....


static Logger ssoLogger;
Appender ssoAppender;
SimpleLayout ssoLayout;

static
{
ssoLogger =
Logger.getLogger(com.americanstandard.lol.common.AccountServlet.class.getName());
ssoLogger.setAdditivity(false);
ssoLogger.setLevel(Level.DEBUG);
}

ssoLayout = new SimpleLayout();
ssoAppender = new FileAppender(ssoLayout, "ssologin.log");
ssoLogger.addAppender(ssoAppender);

//logging statements lower in my code


This is resulting in output like the below. I thought I was going to
get rid of the duplicate entries by calling setAdditivity(false)...see
above code. Any guidance as to how to prevent the entries from being
multiplied will be greatly appreciated. PS....this is a servlet.

George Jempty


FATAL - ********************************************
FATAL - java.lang.NullPointerException
FATAL - null
FATAL - HttpRequestRemoteUser: null
FATAL - ipAddr: 206.44.76.249
FATAL - ticket: null
FATAL - sessionKey: null
FATAL - docBase: loldev
FATAL - userName: null
FATAL - domainName:
FATAL - blnLoginSuccess: true
FATAL - ********************************************
FATAL - ********************************************
FATAL - java.lang.NullPointerException
FATAL - java.lang.NullPointerException
FATAL - null
FATAL - null
FATAL - HttpRequestRemoteUser: null
FATAL - HttpRequestRemoteUser: null
FATAL - ipAddr: 206.44.76.249
FATAL - ipAddr: 206.44.76.249
FATAL - ticket: null
FATAL - ticket: null
FATAL - sessionKey: null
FATAL - sessionKey: null
FATAL - docBase: loldev
FATAL - docBase: loldev
FATAL - userName: null
FATAL - userName: null
FATAL - domainName:
FATAL - domainName:
FATAL - blnLoginSuccess: true
FATAL - blnLoginSuccess: true
 
G

George Jempty

George said:
I'm totally new to log4j. I'm trying to incorporate logging into a
pile of crap -- er, I mean "application" -- I've inherited. I'm doing
this without the benefit of a configuration file, at least on my first
attempt, until I get to understanding log4j better.

<snip code & output>

Solved it myself, but wanted to share my solution, in case there are
better solutions.
I just put "LogManager.shutdown();" in a finally block.

G
 
G

gimme_this_gimme_that

It would be useful if you posted an example.

What do you have something like :

public void D{

pathtolog4jlogger.Log logger = new pathtolog4jlogger.Log(D.class)

public void go() {
try{
/// all code goes here
} finally {
logger.shutdown();
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top