In order to write the logs generated from your application into a separate file (not in the default <j-boss-installation-directory>\...\server.log file), follow these steps:
Start JBoss Administrative Console: In your browser hit http://localhost:9990/console/App.html
Configure A File Handler:
Add A Log Category:
[You can also configure the handler and Log Category by editing the .../standalone/configuration/standalone.xml file of your server directory.]
Happy Logging:
Now you can log using slf4j from your application like:
and all logs of your application will be written to the file-name that you specified for the handler configured above.
I have used EAP 6.2.0 GA (AS 7.3) application server and slf4j (for logging).
Related Links:
JBoss: Configure Logging
slf4j Manual.
Start JBoss Administrative Console: In your browser hit http://localhost:9990/console/App.html
Configure A File Handler:
- Go to Profile --> Core --> Logging --> 'Handler' tab --> 'File' sub-tab and Click 'Add' button.
- In the 'Add File Handlers' pop-up box, enter name, log-level, file-name with extension etc. and 'Save'
- You may also need to further edit the created handler and set 'Auto Flash' and 'Append' to true.
Add A Log Category:
- Now go to the 'Log Categories' tab and click 'Add'. Enter the root package of your project in the 'Name' field (e.g. com.mycompany.myproject).
- Now select (click on) the newly added log-category and click on 'handlers' (under 'Details' section at the bottom).
- Click 'Add' and add the handler that you created previously.
[You can also configure the handler and Log Category by editing the .../standalone/configuration/standalone.xml file of your server directory.]
Happy Logging:
Now you can log using slf4j from your application like:
private static Logger logger = LoggerFactory.getLogger(MyClass.class);
and all logs of your application will be written to the file-name that you specified for the handler configured above.
I have used EAP 6.2.0 GA (AS 7.3) application server and slf4j (for logging).
Related Links:
JBoss: Configure Logging
slf4j Manual.
No comments:
Post a Comment