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

Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

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
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!
CEHJ

:-)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes