Skip to content

Latest commit

 

History

History
163 lines (132 loc) · 5.3 KB

configuration.md

File metadata and controls

163 lines (132 loc) · 5.3 KB

Configuration is located in log-viewer-1.0.3/config.conf, the file has HOCON

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:

logs = [
  {
    path: "**/*.log"
  }
]

you can replace the default configuration with a more accurate configuration like

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.

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.
  } 
]

Network

log-viewer.server.port property specifies the port

log-viewer.server.interface allow to specify the network interface to bind the web UI. Setting log-viewer.server.interface=localhost will disable non-local connections.

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

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

format = {
  type: Log4jLogFormat
  pattern: "%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n"
  charset: UTF-8       
}  

pattern - Format of log lines defined the same way as in Log4j configuration
charset - (optional) file encoding name

Logback format

Log file has been generated by Logback

format = {
  type: LogbackLogFormat
  pattern: "%date{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n"
  charset: UTF-8       
}

pattern - Format of log lines defined the same way as in Logback configuration
charset - (optional) file encoding name

Regex format

Log format can be defined with regular expression. 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.

format = {
  type: RegexLogFormat
  regex: "(?<date>\\d{4}-\\d\\d-\\d\\d_\\d\\d:\\d\\d:\\d\\d\\.\\d{3}) +(?<level>[A-Z]+) +(?<logger>[\\p{javaJavaIdentifierPart}.]+) +- (?<msg>.+)"
  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 for each field name. type is optional, list of available types is here.

charset - (optional) file encoding name