Log Configuration File Examples
You can customize each configuration log file to control the behaviour of the logging for the different components in Moogsoft Onprem.
See Configure Logging for more information on logging.
Default Configuration Files
The default log configuration file for servlets and utilities is as follows:
{ "configuration": { "packages": "com.moogsoft", "monitorInterval": 2, "ThresholdFilter": { "level": "info" }, "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" } } }, "loggers": { "Logger": { "name": "com.moogsoft", "additivity": false, "AppenderRef": [{ "ref": "STDOUT" }], "level": "info" } } } }
The default log configuration file for Moogfarmd is:
{ "configuration": { "packages": "com.moogsoft", "monitorInterval": 2, "ThresholdFilter": { "level": "trace" }, "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" } }, "RollingFile": { "name": "FILE", "fileName": "${sys:MoogsoftLogFilename}", "filePattern": "${sys:MoogsoftLogFilename}-%d{MM-dd-yy}-%i.gz", "PatternLayout": { "header": "${sys:MoogsoftLogHeader}", "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" }, "Policies": { "SizeBasedTriggeringPolicy": { "size": "500M" } }, "DefaultRolloverStrategy": { "max": "40" } } }, "filters" : { "MarkerFilter" : { "marker": "MOOG_ESSENTIAL_INFO", "onMatch": "ACCEPT", "onMismatch": "NEUTRAL" } }, "loggers": { "root": { "additivity": false, "AppenderRef": [{ "ref": "${sys:MoogsoftLogAppender}" }], "level": "warn" }, "Logger": [ { "name": "com.moogsoft", "additivity": false, "AppenderRef": [{ "ref": "${sys:MoogsoftLogAppender}" }], "level": "warn" }, { "name": "com.moogsoft.persistence.serialization.CMiniLogToSlf4jLogger", "additivity": false, "AppenderRef": [{ "ref": "${sys:MoogsoftLogAppender}" }], "level": "error" } ] } }
Asynchronous Appender
You can configure a log file to use an asynchronous appender. This allows you to log event asynchronously. See AsyncAppender for details.
{ "configuration": { "packages": "com.moogsoft", "monitorInterval": 2, "ThresholdFilter": { "level": "info" }, "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" } }, "RollingFile": { "name": "FILE", "fileName": "${sys:MoogsoftLogFilename}", "filePattern": "${sys:MoogsoftLogFilename}-%d{MM-dd-yy}-%i.gz", "PatternLayout": { "header": "${sys:MoogsoftLogHeader}", "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%c]: %message%n" }, "Policies": { "SizeBasedTriggeringPolicy": { "size": "500M" } }, "DefaultRolloverStrategy": { "max": "40" } }, "Async" : { "name": "Async", "AppenderRef": {"ref": "FILE"} } }, "loggers": { "Logger": { "name": "com.moogsoft", "additivity": false, "AppenderRef": [{ "ref": "Async" }], "level": "info" } } } }
Post Logs to OpenSearch
You can configure logs to be posted to OpenSearch using the "Http" section and the 'url
' property direct them to an OpenSearch server:
{ "configuration": { "packages": "com.moogsoft", "monitorInterval": 2, "ThresholdFilter": { "level": "info" }, "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" } }, "RollingFile": { "name": "FILE", "fileName": "${sys:MoogsoftLogFilename}", "filePattern": "${sys:MoogsoftLogFilename}-%d{MM-dd-yy}-%i.gz", "PatternLayout": { "header": "${sys:MoogsoftLogHeader}", "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" }, "Policies": { "SizeBasedTriggeringPolicy": { "size": "500M" } }, "DefaultRolloverStrategy": { "max": "40" } }, "Http": { "name": "OpenSearch", "url": "http://localhost:9200/logs/farmdlogs/", "JsonLayout": { "compact": true, "eventEol": true, "locationInfo": true, "properties": true } } }, "loggers": { "Logger": { "name": "com.moogsoft", "additivity": false, "AppenderRef": [{ "ref": "${sys:MoogsoftLogAppender}" }, { "ref": "OpenSearch" }], "level": "info" } } } }
Save Logs to the Database
You can configure your logs to be saved to the database with a configuration similar to the following:
/* To create the table for the logs to use: CREATE TABLE IF NOT EXISTS logs(time TIMESTAMP, message TEXT, level TEXT, logger TEXT, exception TEXT); */ { "configuration": { "packages": "com.moogsoft", "monitorInterval": 2, "ThresholdFilter": { "level": "info" }, "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" } }, "RollingFile": { "name": "FILE", "fileName": "${sys:MoogsoftLogFilename}", "filePattern": "${sys:MoogsoftLogFilename}-%d{MM-dd-yy}-%i.gz", "PatternLayout": { "header": "${sys:MoogsoftLogHeader}", "pattern": "%-5level: [%thread][%date{yyyMMdd HH:mm:ss.SSS Z}] [%file:%line] +|%message|+%n" }, "Policies": { "SizeBasedTriggeringPolicy": { "size": "500M" } }, "DefaultRolloverStrategy": { "max": "40" } }, "JDBC" : { "name": "DB", "tableName": "logs", "DriverManager": { "connectionString": "jdbc:mysql://localhost:3306/moogdb??useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&connectTimeout=5000&rewriteBatchedStatements=true&cacheCallableStmts=true&cachePrepStmts=true&callableStatementCacheSize=1000&prepStmtCacheSize=1000&prepStmtCacheSqlLimit=100000&useCursorFetch=true&useSSL=false", "userName": "ermintrude", "password": "m00" }, "Column": [{ "name": "time", "isEventTimestamp": true }, { "name": "message", "pattern": "%message" }, { "name": "level", "pattern": "%level" }, { "name": "logger", "pattern": "%logger" }, { "name": "exception", "pattern": "%ex{full}" } ] } }, "loggers": { "Logger": { "name": "com.moogsoft", "additivity": false, "AppenderRef": [{ "ref": "${sys:MoogsoftLogAppender}" }, {"ref": "DB"}], "level": "info" } } } }