Logging Configuration for pmlogd

Caution
The content in this page is only applicable to the environment where pmlogd is enabled. To find out how to enable pmlogd, see Enabling and Disabling pmlogd.

pmlogd provides logging configuration methods to set the log level and log file by each context.

A configuration file is used to create context(s) for your component and configure the context settings as needed. It must be added to the component’s files/conf/pmlog/<filename>.conf and installed in (WEBOS_INSTALL_SYSCONFDIR)/pmlog.d.

The format and content of the configuration file must be as follows:

{
     "contexts" : [
          {
               "name" : "mycontext",
               "level" : "info".
               "logProcessIds" : false,
               "logThreadIds" : false,
               "logToConsole" : false,
               "rules" : [
                    { "filter" : "*.*", "output" : "mycontext_log" }
               ]
          }
     ],
     "outputs" : [
          {
               "name" : "mycontext_log",
               "file" : "<at:var at:name="WEBOS_INSTALL_LOGDIR" />/mycontext.log",
               "maxSize": 2000,
               "rotations" : 5
          }
     ]
}
Note
Please note that it is not mandatory to configure your context. You can just call PmLogGetContext() to create a new context, whose settings will take the default values.

Contexts Section

Here you can specify logging context names and what the default level should be for them. Changes to the Contexts section will only be read at boot time. If you change this section, device has to be rebooted or use PmLogCtl app to see real time changes without rebooting.

The <default> context is specially defined, otherwise client context names should follow the regular rules, i.e. use alphanumeric characters only and use a period (".") to separate component hierarchies.

ParameterDescription

level

One of the standard pmlog levels or none to disable logging.

logProcessIds

Enables to turn on process ID tagging.

logThreadIds

Enables to turn on thread ID tagging.

logToConsole

Enables to turn on stdout output.

bufferSize

[OPTIONAL - integer] The ring buffer size for a context

flushLevel

[OPTIONAL - integer] The flush level for a ring buffer. This is one of the pmlog levels.

rules

Specifies routing rules for each context. A rule specifies filter and output.

rules.filter

A filter format is as follows:

<facility>[.<level>[.<program>]]
  • facility: One of the standard syslog facilities or use an asterisk ("*") to indicate all. See the Wikipedia page for details.
  • level: One of the standard syslog levels or use an asterisk ("*") to indicate all. When specifying a level, it implicitly matches that level or higher. The level may be prefixed with '!' to match only lower levels.
  • program: Specify an exact program name or use an asterisk ("*") to indicate all.

rules.output

Indicates one of the named output targets previously defined. If a single quote (' ') is specified before the output, it indicates that the specified filter should omit matched messages.

Outputs Section

Each output defines settings for a particular log file.

ParameterDescription
file
Path to file.
maxSize
Maximum size the file can reach before rotation.
rotations
The maximum number of rotations before rotating files out the oldest files.

All context logs are routed to /var/log/messages by default. However, if you want to route context logs to a particular file, you should create a configuration file as above format in /etc/pmlog.d/ directory and set the contextLogging parameter to true as shown in line 23 below in /etc/pmlog.d/default.conf. Then, each component logs are written in an individual file separately.

The /etc/pmlog.d/default.conf has the following default format:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
     "contexts" : [
          {
               "name" : "<default>",
               "level" : "info".
               "logProcessIds" : false,
               "logThreadIds" : false,
               "logToConsole" : false,
               "rules" : [
                    { "filter" : "*.*", "output" : "stdlog" },
                    { "filter" : "kern.!info", "output" : "-stdlog" }
               ]
          }
     ],
     "outputs" : [
          {
               "name" : "stdlog",
               "file" : "/var/log/messages",
               "maxSize" : 2000,
               "rotations" : 5
          }
     ],
     "contextLogging" : false
}

After changing the value of contextLogging parameter, device needs to be rebooted.

Contents