Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get JBoss log directory

Tags:

jboss

We need to display JBoss log files from within our web application. Is it possible to achieve this without using ServerConfigLocator ? The application must be able to run also with Websphere and we don't want dependencies on specific JARs.

like image 506
Lluis Martinez Avatar asked Feb 08 '10 09:02

Lluis Martinez


People also ask

How do I read JBoss logs?

To monitor the log file (e.g. server. log) you can use the tail -f command in this case Linux / Cygwin. It is real-time reading the log and with Ctrl + C command you can close the tail -f command and not lose any of your data (you can open it again with any text editor). Note: path/jboss-eap-6.0/standalone/log/server.

What is JBoss server base dir?

jboss.server.base.dir/configuration. jboss.server.data.dir. The directory used for persistent data file storage.

What is the directory structure in JBoss?

The conf directory contains the jboss-service. xml bootstrap descriptor file for a given server configuration. This defines the core services that are fixed for the lifetime of the server. The data directory is available for use by services that want to store content in the file system.


2 Answers

JBoss's defined log directory is held in the jboss.server.log.dir system property. You can resolve that directory to a java.io.File, and read the files inside.

File logDir = new File(System.getProperty("jboss.server.log.dir"));
logDir.list(); // etc etc

You can also get this through ServerConfig.getServerLogDir() (on JBoss 4.x, anyway), but you said you wanted to avoid JAR dependencies.

like image 76
skaffman Avatar answered Oct 21 '22 09:10

skaffman


You could use a custom log implementation. This would give you complete control over the logging behavior.

JBoss uses Log4j as its logging mechanism. WebSphere uses Jakarta Commons Logging, which can be configured to delegate to Log4j if it isn't already the default. If you already use Log4j in your application then I don't expect that this difference will cause you any new problems.

like image 34
richj Avatar answered Oct 21 '22 11:10

richj