Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 31st, 2007, 9:40 AM   #1
tsofras
Programmer
 
tsofras's Avatar
 
Join Date: Jul 2005
Location: Athens,Greece
Posts: 39
Rep Power: 0 tsofras is an unknown quantity at this point
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?
tsofras is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
jsp and java servlet cairo Java 5 May 31st, 2007 1:05 AM
Servlet problems paulchwd Java 4 Mar 3rd, 2007 1:41 PM
[java] servlet and mysql problem C41R0 Java 4 Oct 12th, 2006 12:09 AM
jsp & servlet tutorials bae Java 1 Feb 10th, 2006 10:41 PM
Cant connect servlet to MySQL DB BizzyC Java 0 Mar 8th, 2005 9:01 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:55 PM.

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