Configuration is located in `log-viewer-1.0.10/config.conf`, the file has [HOCON](https://github.com/lightbend/config) ### List of available log files A list of available log files are defined in `logs = [ ... ]` section of the configuration file. The default configuration gives access to all files with ".log" extension: ```hocon logs = [ { path: "**/*.log" } ] ``` you can replace the default configuration with a more accurate configuration like ```hocon logs = [ { path: ${HOME}"/one-app/logs/*.log" }, { path: ${HOME}"/second-app/logs/*.log" }, { path: "/var/log/syslog" } ] ``` Each `{ path: "..." }` section opens access to log files by a pattern. The pattern supports wildcards "*" matches a sequence of any characters except "/", "**" matches a sequence of any characters include "/".
${HOME} will be replaced with the environment variable "HOME", it is a feature of [HOCON](https://github.com/lightbend/config#uses-of-substitutions). ### Authentication #### Basic authentication Basic authentication may be configured. The list of users can be defined in `users = [...]` section. Passwords can be defined as plain text or as MD5 checksum. Example: ``` authentication.enabled = true users = [ { name: "user1", password: "1" }, { name: "user2", password-md5: "c81e728d9d4c2f636f067f89cc14862c" // The password is "2". Specified as md5 hash of "2" string. } ] ``` #### LDAP authentication LDAP authentication may be configured. Example: ``` authentication.enabled = true authentication.ldap.enabled = true ldap-config = { roles: ["user"] // user access groups debug: "false" useLdaps: "false" hostname: "ldap.example.com" port: "389" bindDn: "cn=Directory Manager" bindPassword: "directory" authenticationMethod: "simple" forceBindingLogin: "true" userBaseDn: "ou=people,dc=alcatel" userRdnAttribute: "sAMAccountName" userIdAttribute: "sAMAccountName" userPasswordAttribute: "unicodePwd" userObjectClass: "user" roleBaseDn: "ou=groups,dc=example,dc=com" roleNameAttribute: "cn" roleMemberAttribute: "member" roleObjectClass: "group" } ``` ### Network `log-viewer.server.port` property specifies the port for the web interface `log-viewer.server.interface` property specifies the network interface to bind the web interface. E.g. `log-viewer.server.interface=localhost` disables non-local connections. `log-viewer.backdoor_server.port` property specifies the port used by Log-Viewer instances from other machines to load logs from the current machine. "9595" by default. `log-viewer.server.enabled` whether to run the web server or not. Log-viewer may be used as an agent for other Log-Viewer instances only (see `log-viewer.backdoor_server.port`) ### Shortcuts Full file paths don't look good in the URL parameters. You can specify a shortcut for one or several log files in `log-paths` section
Example: ``` log-paths = { zzz = { file = [${HOME}"/my-app/logs/my-app.log", ${HOME}"/aother-app/logs/aother-app.log"] } } ``` When user opens `http://localhost:8111/log?log=zzz`, he will see the events from `my-app.log` and `aother-app.log` on one page. You can specify the logs located on other nodes as well: ``` log-paths = { zzz = { file = ${HOME}"/my-app/logs/my-app.log" host = ["node-cn-01", "node-cn-02", "node-cn-03"] } } ``` `http://localhost:8111/log?log=zzz` page will show events from `my-app.log` files located on the 3 remote nodes.
Note: `node-cn-01`, `node-cn-02` and `node-cn-03` must have running Log-Viewer instances. ### Log format LogViewer detects the format of log files automatically. If the format cannot be detected automatically or if you want to specify the format more detailed, you can add `format` section beside `path` definition. In the following example all files with ".log" extension in `${HOME}"/my-app/logs` directory will be parsed as Log4J generated logs with pattern `%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n` ```hocon logs = [ { path: ${HOME}"/my-app/logs/*.log" format = { type: Log4jLogFormat pattern: "%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n" } } ] ``` `format` property contains an object that defines a log format. The object must contain `type` property. Other properties depend on format type. The configuration supports the following format types: ###### Log4J format Log file has been generated by [Log4J](https://logging.apache.org/log4j/2.x/index.html) ```hocon format = { type: Log4jLogFormat pattern: "%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n" charset: UTF-8 locale: en_US customLevels: ["XXX", "YYY"] } ``` `pattern` - Format of log lines defined the same way as in [Log4j configuration](https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout)
`patterns` - A list of possible log line formats. May be used when the log contains lines in diffrent formats. Either `pattern` or `patterns` fields must be present
`charset` - _(optional)_ file encoding name
`locale` - _(optional)_ custom locale
`customLevels` - _(optional)_ custom levels
###### Logback format Log file has been generated by [Logback](http://logback.qos.ch/) ```hocon format = { type: LogbackLogFormat pattern: "%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n" charset: UTF-8 locale: en_US customLevels: ["XXX", "YYY"] } ``` `pattern` - Format of log lines defined the same way as in [Logback configuration](http://logback.qos.ch/manual/layouts.html)
`patterns` - A list of possible log line formats. May be used when the log contains lines in diffrent formats. Either `pattern` or `patterns` fields must be present
`charset` - _(optional)_ file encoding name
`locale` - _(optional)_ custom locale
`customLevels` - _(optional)_ custom levels
###### Regex format Log format can be defined with [regular expression](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html). The log parser applies the regex to each line in the log. If a line matches regex, it is a log event, if not, the line will be appended to a log event above the line. ```hocon format = { type: RegexLogFormat regex: "(?\\d{4}-\\d\\d-\\d\\d_\\d\\d:\\d\\d:\\d\\d\\.\\d{3}) +(?[A-Z]+) +(?[\\p{javaJavaIdentifierPart}.]+) +- (?.+)" charset: UTF-8 fields: [ { name: "date", type: "date" }, { name: "level", type: "level/log4j" }, { name: "logger", type: "class" }, { name: "msg", type: "message" }, ] } ``` `regex` - a regex applying to each line `fields` - list of log fields. Each field description has `name` and `type`. Regex must contain [named capturing groups](https://www.logicbig.com/tutorials/core-java-tutorial/java-regular-expressions/named-captruing-groups.html) for each field name. `type` is optional, list of available types is [here](to_be_done). `charset` - _(optional)_ file encoding name