Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   2 Loggers in the same Servlet.... (http://www.programmingforums.org/showthread.php?t=13256)

tsofras May 31st, 2007 10:40 AM

2 Loggers in the same Servlet....
 
Hello guys i have a little problem.

I have a servlet and i create 2 Loggers , that each one is writing to a different file. The problem is , when i open the files i can see that both Loggers are writing to both files, i will give an example later.
I found out that if i create the new Logger with newInstance() the problem dissapears, but i am not confident to do it on the Servlet.

Here is my code:

:

static Logger appLogger = Logger.getLogger(checkLogin.class);
static Logger hol_appLogger = Logger.getLogger(checkLogin.class);

FileAppender appender = null;
FileAppender hol_appender = null;

try
{
appender = new FileAppender(new PatternLayout(),"C:\\logs\\log1.log");
hol_appender = new FileAppender(new PatternLayout(),"C:\\logs\\log2.
}
catch (Exception e)
{
    e.getMessage();
}

appLogger.addAppender(appender);
appLogger.setLevel(Level.DEBUG);           

hol_appLogger.addAppender(hol_appender);
hol_appLogger.setLevel(Level.DEBUG);

appLogger.info("AppLoger");
hol_appLogger.info("HolAppLoger");


At the end , both file will have both info .

P.S. i am not able to config log4j from property file, because of some security problems

Any idea?


All times are GMT -5. The time now is 2:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC