logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sachin Wadhwa <swad...@dwl.com>
Subject Re: Logging into Files
Date Wed, 04 Apr 2001 21:30:51 GMT
Hi Pradipta,
Instead of calling BasicConfigurator(), call BasiConfigurator with Appender as
an argument.
Here is the sample code
=================================================
java.io.OutputStream os = null;
 try{
  os = new FileOutputStream("C:\\Test.log.txt",true); //mind you double slash
after c:
 }catch(IOException e){
  System.out.println("Could not open file");
  return;
 }
 Appender myAppender = new FileAppender(new
PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN), os);
BasicConfigurator.configure(myAppender);
========================================

Hope it works

Sac


Pradipta Chatterjee wrote:

> Hi,
> I am a beginner to the Log4J community and was inetersted to use this to log
> my Sys.out to specific txt files.
>
> My Code
> =======
> import org.apache.log4j.*;
>
> public class Class1 {
>       public static void main(String args[]){
>           BasicConfigurator.configure();
>
>         Category cat = Category.getInstance(Class1.class.getName());
>
>           //cat.addAppender(A1); ******* I tried this step but could not
> follow how to direct output to a file
>
>         cat.setPriority(Priority.DEBUG);
>         cat.warn("Low fuel level.");
>         cat.debug("Starting search for nearest gas station.");
>       }//end of main
>
> }//end of Class1
>
> The Purpose of my application is to direct the Sys.out to a log file say
> C:\Test.log.txt.
> Obviously I am missing something....some intermediate step.
>
> Can anyone please let me know how to solve this? Any URL or sample code is
> welcome.
>
> I apologise for sounding so illiterate.
>
> Thanks and Regards,
>
> Prodi.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org

--
Sachin Wadhwa
Product Developer
DWL Incorporated
230 Richmond Street East Level 2
Toronto, ON
M5A 3X9
T: (416)364-2045 x 2463
F: (416)364-2422
www.dwl.com



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message