RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Tim Davidson
I've done it! I was missing the first '/' i.e.

URL url = this.getClass().getResource(/com/foo/bar/message.properties);

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 4:23 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs



Howdy,

yeah, I'm using ant but I dont like the fact that it is hard-coded.

It's not hard-coded, certainly not more hard-coded than a properties
file.

 I think I'll use the properties file option, we have a properties file
already I'll just add the log4j properties to that. I don't suppose you
know how to load the properites file when it is in a JAR? because it
says

If the file is in a jar, use Class#getResource to get the URL to it.
Don't use the File/IO approach.  Then use
PropertyConfigurator.configure(URL configURL) instead of
configure(Properties p).

You can also consider putting the properties file outside a jar, i.e.
under WEB-INF, and using the ServletContext#getResource approach instead
of Class#getResource.  This way you can easily modify the properties
file without having to repackage your jar.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Tim Davidson
yeah, I'm using ant but I dont like the fact that it is hard-coded.
 I think I'll use the properties file option, we have a properties file already I'll 
just add the log4j properties to that. I don't suppose you know how to load the 
properites file when it is in a JAR? because it says in the log4j FAQ the log4j 
classes and the properties file are not within the scope of the same 
classloader.So, if you're having problems, try loading the class or resource 
yourself. 
 what i've done already is:

 Properties p = new Properties();
 FileInputStream fis;
try
{
fis = new FileInputStream(com.foo.bar.message.properties);
p.load(fis);
}
catch (Throwable t)
{
t.printStackTrace();
} 

PropertyConfigurator.configure(p);

 but its not picking up our file in the JAR

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 2:42 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs



Howdy,

 Thanks, thats a help but because of the setup of our application, I
cant
use the first two options, and I'd rather not define another properties
file just to store ${CATALINA_HOME}/logs/logs.txt. Is there any way I
can
do it programatically? What are the other options?

No.  It would be against the spirit, if not the letter, or the servlet
specification for a servlet to be able to find out such details about
its container.  Even the approaches I showed before weren't that
portable.  This is like those perennial how can I find out what port
the server is running on in my servlet's init() method? (You can't with
certainty/portability).

Other options include adding a JNDI entry for your log file path into
tomcat's server.xml and then doing a JNDI lookup in your servlet's init
method, or mangling your log4j configuration together with tomcat's
commons-logging configuration.  The latter is just cruising for a
bruising, and the former is too container-specific (requires modifying
server.xml) for my preferences, so I didn't include them before.

Typically the Ant option is the one I like best, but I guess you don't
use Any to deploy/package your application?

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Jacob Kjome
Just use default initialization or use the InitContextListener that I 
created in the log4j-sandbox project..

http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/AppContainerLogging

Jake

At 03:48 PM 8/12/2003 +0100, you wrote:
yeah, I'm using ant but I dont like the fact that it is hard-coded.
 I think I'll use the properties file option, we have a properties file 
already I'll just add the log4j properties to that. I don't suppose you 
know how to load the properites file when it is in a JAR? because it says 
in the log4j FAQ the log4j classes and the properties file are not 
within the scope of the same classloader.So, if you're having 
problems, try loading the class or resource yourself. 
 what i've done already is:

 Properties p = new Properties();
 FileInputStream fis;
try
{
fis = new FileInputStream(com.foo.bar.message.properties);
p.load(fis);
}
catch (Throwable t)
{
t.printStackTrace();
}
PropertyConfigurator.configure(p);

 but its not picking up our file in the JAR

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 2:42 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs


Howdy,

 Thanks, thats a help but because of the setup of our application, I
cant
use the first two options, and I'd rather not define another properties
file just to store ${CATALINA_HOME}/logs/logs.txt. Is there any way I
can
do it programatically? What are the other options?
No.  It would be against the spirit, if not the letter, or the servlet
specification for a servlet to be able to find out such details about
its container.  Even the approaches I showed before weren't that
portable.  This is like those perennial how can I find out what port
the server is running on in my servlet's init() method? (You can't with
certainty/portability).
Other options include adding a JNDI entry for your log file path into
tomcat's server.xml and then doing a JNDI lookup in your servlet's init
method, or mangling your log4j configuration together with tomcat's
commons-logging configuration.  The latter is just cruising for a
bruising, and the former is too container-specific (requires modifying
server.xml) for my preferences, so I didn't include them before.
Typically the Ant option is the one I like best, but I guess you don't
use Any to deploy/package your application?
Yoav Shapira



This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, 
proprietary and/or privileged.  This e-mail is intended only for the 
individual(s) to whom it is addressed, and may not be saved, copied, 
printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your 
computer system and notify the sender.  Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Shapira, Yoav

Howdy,

 Thanks, thats a help but because of the setup of our application, I
cant
use the first two options, and I'd rather not define another properties
file just to store ${CATALINA_HOME}/logs/logs.txt. Is there any way I
can
do it programatically? What are the other options?

No.  It would be against the spirit, if not the letter, or the servlet
specification for a servlet to be able to find out such details about
its container.  Even the approaches I showed before weren't that
portable.  This is like those perennial how can I find out what port
the server is running on in my servlet's init() method? (You can't with
certainty/portability).

Other options include adding a JNDI entry for your log file path into
tomcat's server.xml and then doing a JNDI lookup in your servlet's init
method, or mangling your log4j configuration together with tomcat's
commons-logging configuration.  The latter is just cruising for a
bruising, and the former is too container-specific (requires modifying
server.xml) for my preferences, so I didn't include them before.

Typically the Ant option is the one I like best, but I guess you don't
use Any to deploy/package your application?

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Tim Davidson
I'm not having much luck with this, as you suggested I changed from input stream to 
URL, but i've tried everything and it doesn't want to pick up the file. This is what I 
have:

URL url = this.getClass().getResource(com/foo/bar/message.properties);
PropertyConfigurator.configure(url);

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 4:23 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs



Howdy,

yeah, I'm using ant but I dont like the fact that it is hard-coded.

It's not hard-coded, certainly not more hard-coded than a properties
file.

 I think I'll use the properties file option, we have a properties file
already I'll just add the log4j properties to that. I don't suppose you
know how to load the properites file when it is in a JAR? because it
says

If the file is in a jar, use Class#getResource to get the URL to it.
Don't use the File/IO approach.  Then use
PropertyConfigurator.configure(URL configURL) instead of
configure(Properties p).

You can also consider putting the properties file outside a jar, i.e.
under WEB-INF, and using the ServletContext#getResource approach instead
of Class#getResource.  This way you can easily modify the properties
file without having to repackage your jar.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Tim Davidson
 Thanks, thats a help but because of the setup of our application, I cant use the 
first two options, and I'd rather not define another properties file just to store 
${CATALINA_HOME}/logs/logs.txt. Is there any way I can do it programatically? What are 
the other options?
 I have searched at the tomcat-user-list archives, and I have even googled for log4j 
tomcat logs but without much luck.

 any help would be appreciated

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 1:45 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs



Howdy,

 this may be more a tomcat question so appologies if it is off-topic.
 I want to plcae the log file under %TOMCAT_HOME%\logs (where all the
tomcat logs go).

Reading the archives of this list or the tomcat-user list would've
revealed answers, as this is a fairly common question.

 I have defined in web.xml:

  servlet
 servlet-nameMyServlet/servlet-name
 servlet-classfoo.bar.MyServlet/servlet-class
init-param
  param-namelogfile/param-name
  param-valuelogs.txt/param-value
/init-param
  /servlet

and in the servlet:

String logFile = getInitParameter(logfile);
appender = new FileAppender(layout, logFile);

You have a number of options, including:

- Setting param-value in web.xml to be an ant token, e.g.
param-value@logFilePath@/param-value
and have Ant fill in this token from whatever properly you want, e.g.
$CATALINA_HOME/logs/logs.txt, when it's deploying web.xml.

- Adding -DCATALINA_HOME=$CATALINA_HOME to your JAVA_OPTS in
$CATALINA_HOME/bin/catalina.sh so that you can get Catalina home via
System.getProperty(), then do 
String logFile = System.getProperty(CATALINA_HOME) + /logs/ +
getInitParameter(logFile);

- Using a log4j configuration file, rather than programmatic
configuration, and having something like
log4j.myAppender=org.apache.log4j.FileAppender
log4j.myAppneder.File=${CATALINA_HOME}/logs/logs.txt
...

There are other options as well.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-14 Thread Shapira, Yoav

Howdy,

 this may be more a tomcat question so appologies if it is off-topic.
 I want to plcae the log file under %TOMCAT_HOME%\logs (where all the
tomcat logs go).

Reading the archives of this list or the tomcat-user list would've
revealed answers, as this is a fairly common question.

 I have defined in web.xml:

  servlet
 servlet-nameMyServlet/servlet-name
 servlet-classfoo.bar.MyServlet/servlet-class
init-param
  param-namelogfile/param-name
  param-valuelogs.txt/param-value
/init-param
  /servlet

and in the servlet:

String logFile = getInitParameter(logfile);
appender = new FileAppender(layout, logFile);

You have a number of options, including:

- Setting param-value in web.xml to be an ant token, e.g.
param-value@logFilePath@/param-value
and have Ant fill in this token from whatever properly you want, e.g.
$CATALINA_HOME/logs/logs.txt, when it's deploying web.xml.

- Adding -DCATALINA_HOME=$CATALINA_HOME to your JAVA_OPTS in
$CATALINA_HOME/bin/catalina.sh so that you can get Catalina home via
System.getProperty(), then do
String logFile = System.getProperty(CATALINA_HOME) + /logs/ +
getInitParameter(logFile);

- Using a log4j configuration file, rather than programmatic
configuration, and having something like
log4j.myAppender=org.apache.log4j.FileAppender
log4j.myAppneder.File=${CATALINA_HOME}/logs/logs.txt
...

There are other options as well.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie how to place logfile under tomcat logs

2003-08-12 Thread Shapira, Yoav

Howdy,

yeah, I'm using ant but I dont like the fact that it is hard-coded.

It's not hard-coded, certainly not more hard-coded than a properties
file.

 I think I'll use the properties file option, we have a properties file
already I'll just add the log4j properties to that. I don't suppose you
know how to load the properites file when it is in a JAR? because it
says

If the file is in a jar, use Class#getResource to get the URL to it.
Don't use the File/IO approach.  Then use
PropertyConfigurator.configure(URL configURL) instead of
configure(Properties p).

You can also consider putting the properties file outside a jar, i.e.
under WEB-INF, and using the ServletContext#getResource approach instead
of Class#getResource.  This way you can easily modify the properties
file without having to repackage your jar.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]