tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Triptpal Singh Lamba" <tr...@cs.sunysb.edu>
Subject Re: Logging to catalina logger
Date Mon, 02 Dec 2002 01:08:04 GMT
I dont know abt the cataline logger,I am using a small method I wrote and it
is working fine right now.



import java.io.FileWriter;

import java.io.IOException;

import java.util.Calendar;

import java.util.TimeZone;

public class Logger {

static FileWriter out = null;

static String filePath = "";

public boolean pathFound =false;


public void setPath(String path) {

System.out.println("Path for logger set = " + path);

this.pathFound = true ;

filePath = path;

}



synchronized public static void log(String message) {

try {

Calendar cal = Calendar.getInstance(TimeZone.getDefault());

String DATE_FORMAT = "dd_MM_yyyy";

java.text.SimpleDateFormat sdf =

new java.text.SimpleDateFormat(DATE_FORMAT);

if (out == null) {

out =

new FileWriter(

filePath

+ "ospLogs"

+ sdf.format(cal.getTime())

+ ".txt",

true);

System.out.println(

"Path we made is = "

+ filePath

+ "ospLogs"

+ sdf.format(cal.getTime())

+ ".txt");

}

out.write(message + "\n");

out.flush();

} catch (IOException e) {

System.out.println(

"Caught IOException in logger = " + e.getMessage());

} catch (Exception e) {

System.out.println(

"Caught General Exception in logger " + e.getMessage());

}

}

}

----- Original Message -----
From: "Peter Lee" <tomcatuser@shaw.ca>
To: <tomcat-user@jakarta.apache.org>
Sent: Sunday, December 01, 2002 8:05 PM
Subject: Logging to catalina logger


> How  do I produce log output to the catalina loggerwhen my program wants
to print out
> some exceptions or messages? Any documents on this?
>
> Thanks
>
> --
> To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>
>
>
>



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message