Link to home
Create AccountLog in
Avatar of pbenito
pbenito

asked on

How can use the built in logger utility to wirte log messages to a file?

Hi,
 
   I am new to JDK 6 and want to have my log output go to a file AND the console.  The below code works for me, but it only writes to the console.  Any suggestions on how to make it write to a file AND console?

Thanks!
Logger l = Logger.getAnonymousLogger();
        l.setLevel(Level.ALL);
        
        String wsAddress = "http://localhost:8765/";
        Endpoint.publish(wsAddress, new TestWebService());
        l.log(Level.INFO,"The web service started.  It can be located at " + wsAddress);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html

Bear in mind that most professional programs use log4j, not the JDK logging API
Avatar of pbenito
pbenito

ASKER

Understood....I'm having an issue importing the log4j jar into NetBeans....maye you can help with this issue too!

https://www.experts-exchange.com/questions/23321673/Why-can't-I-import-the-log4j-jar-library.html

Thanks!
:-)