-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Routing engine Logging #2
Comments
Configuring Log4j2OverviewThe logger configuration has 3 main components
Each log in the code goes through these. PropertiesIn the < Properties > < /Properties > we can define key value pairs and refer to these in other components of the configuration. LoggerLogger help in filtering which files and levels should be logged. The job of logger is to extract specific logs from all incoming logs based on the properties. We can set the following properties -
If a logger1 is configured for name= apache. org and logger2 is configured for name = apache.org.xyz by default the logger2 logs will go to logger1 also, unless additivity is set to false. Root Logger
We can specify AppenderRef to configure any particular appender we want to use. AppenderThe filtered logs are sent to specified appender. Appender are responsible for delivering log events to their destination. This answer specifically addressed how to log event of a specific class or package, write them to a separate file and how to configure whether the logs should be sent out to the console. Logging specific class or packageIn this file a custom logger is created to filter log event of test3.groovy file -
This filters log events in the test3 file, since additivity is set to false these events are not passed to the "org.moqui" logger or the root logger. Appender ref specifies which Appender will consume this log event. Logging specfic events based on conditionsThread Context MapLog4j provides a ThreadContextMap, in which we can store key value pairs associated with a specific thread, these values are accessible in the log4j configurable file. To use it we need to import in our java/groovy file-
We can later access this value and use it to route the log events. Appending filtered log to filesWe can can define Routes in RoutingAppender and redirect LogEvents based on the values we put in Thread Context Map.
Here we are checking if "identifier" we put earlier in Thread Context Map is null, if not we use it as a property in the pattern to create log file name. Logging to consoleCurrently this log is sent to RoutingAppender only which saves it into a log file. To send any Log Event to console it should be passed to < Console > Element which is present inside
Logging to multiple Appenders and ConsoleTo send LogEvents to multiple Appenders, we can utilise the Async Appender. Async Appender
This will send the log events to Routing Appender as well as to the Console. |
Moqui Framework provides a versatile logging system that can be adapted for various use cases.
The Moqui logging system leverages SLF4J (Simple Logging Facade for Java) as its logging facade, with Log4J2 as the default logging implementation. This setup allows for flexible logging configuration, including file, console, and external systems logging, with support for different log levels (e.g., DEBUG, INFO, WARN, ERROR).
The text was updated successfully, but these errors were encountered: