You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Matthew Westwood-Hill <ma...@nuix.com> on 2013/12/09 06:46:17 UTC
Configure Tomcat Logging Programmatically
I am running Tomcat programmatically (embedded) and I wanted to configure
its logging so I can track inbound request.
I start Tomcat as follows:
tomcat = new Tomcat();
tomcat.setBaseDir(DEFAULT_BASE_DIR);
tomcat.getService().addConnector(defaultConnector);
tomcat.setConnector(defaultConnector);
tomcat.init();
tomcat.start();
How do I go about configuring the logging?
Cheers,
Matt
Re: Configure Tomcat Logging Programmatically
Posted by java developer <re...@gmail.com>.
Hi,
Calling tomcat.setSilent(false) might help. Just try this and see if this
helps. Below is small funcation from Tomcat class.
/**
* Controls if the loggers will be silenced or not.
* @param silent <code>true</code> sets the log level to WARN for the
* loggers that log information on Tomcat start up.
This
* prevents the usual startup information being logged.
* <code>false</code> sets the log level to the default
* level of INFO.
*/
public void setSilent(boolean silent) {
for (String s : silences) {
if (silent) {
Logger.getLogger(s).setLevel(Level.WARNING);
} else {
Logger.getLogger(s).setLevel(Level.INFO);
}
}
}
On Mon, Dec 9, 2013 at 11:16 AM, Matthew Westwood-Hill <
matthew.westwood-hill@nuix.com> wrote:
> I am running Tomcat programmatically (embedded) and I wanted to configure
> its logging so I can track inbound request.
>
>
>
> I start Tomcat as follows:
>
>
>
> tomcat = new Tomcat();
>
> tomcat.setBaseDir(DEFAULT_BASE_DIR);
>
> tomcat.getService().addConnector(defaultConnector);
>
> tomcat.setConnector(defaultConnector);
>
> tomcat.init();
>
> tomcat.start();
>
>
>
> How do I go about configuring the logging?
>
>
>
> Cheers,
>
> Matt
>