Skip to content

Commit

Permalink
Doc changes for log4j upgrade (#981)
Browse files Browse the repository at this point in the history
* Doc changes for log4j upgrade

* Update docs/logging.md

Co-authored-by: Frank Liu <[email protected]>

* Update docs/logging.md

Co-authored-by: Frank Liu <[email protected]>

* Update docs/logging.md

Co-authored-by: Frank Liu <[email protected]>

Co-authored-by: Frank Liu <[email protected]>
  • Loading branch information
maaquib and frankfliu authored Dec 15, 2021
1 parent b1160c6 commit 6524fcf
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docker/advanced_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Notes on a couple of the parameters:
in the range of 0 .. (num-gpu-1) in a round-robin fashion. **By default MMS uses all the available GPUs but this parameter can be configured if user want to use only few of them**.

```properties
# vmargs=-Xmx1g -XX:MaxDirectMemorySize=512m -Dlog4j.configuration=file:///opt/ml/conf/log4j.properties
# vmargs=-Xmx1g -XX:MaxDirectMemorySize=512m -Dlog4j.configurationFile=file:///opt/ml/conf/log4j2.xml
# model_store=/opt/ml/model
# load_models=ALL
# inference_address=http://0.0.0.0:8080
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ User can following parameters to start MMS, those parameters will override defau
* **--mms-config** MMS will load specified configuration file if MMS_CONFIG_FILE is not set.
* **--model-store** This parameter will override `model_store` property in config.properties file.
* **--models** This parameter will override `load_models' property in config.properties.
* **--log-config** This parameter will override default log4j.properties.
* **--log-config** This parameter will override default log4j2.xml
* **--foreground** This parameter will run the model server in foreground. If this option is
disabled, the model server will run in the background.

Expand Down
57 changes: 29 additions & 28 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ In this document we will go through logging mechanism in Multi Model Server. We
metrics, as metrics are logged into a file. To further understand how to customize metrics or define custom logging layouts, refer to the [metrics document](metrics.md)

# Pre-requisites
Before getting into this tutorials, you must familiarize yourself with log4j configuration properties. Refer to this online [document](https://logging.apache.org/log4j/2.x/manual/configuration.html)
on how to configure the log4j parameters. Similarly, familiarize yourself with the default [log4j.properties](../frontend/server/src/main/resources/log4j.properties) used by
Multi Model Server.
Before getting into this tutorials, you must familiarize yourself with log4j2 configuration. Refer to this online [document](https://logging.apache.org/log4j/2.x/manual/configuration.html) on how to configure the log4j2 parameters. Similarly, familiarize yourself with the default [log4j2.xml](../frontend/server/src/main/resources/log4j2.xml) used by Multi Model Server.

# Types of logs
Multi Model Server currently provides three types of logs.
Expand All @@ -15,16 +13,18 @@ Multi Model Server currently provides three types of logs.

## Access Logs:
These logs collect the access pattern to Multi Model Server. The configuration pertaining to access logs are as follows,
```properties
log4j.logger.ACCESS_LOG = INFO, access_log


log4j.appender.access_log = org.apache.log4j.RollingFileAppender
log4j.appender.access_log.File = ${LOG_LOCATION}/access_log.log
log4j.appender.access_log.MaxFileSize = 100MB
log4j.appender.access_log.MaxBackupIndex = 5
log4j.appender.access_log.layout = org.apache.log4j.PatternLayout
log4j.appender.access_log.layout.ConversionPattern = %d{ISO8601} - %m%n
```xml
<RollingFile
name="access_log"
fileName="${env:LOG_LOCATION:-logs}/access_log.log"
filePattern="${env:LOG_LOCATION:-logs}/access_log.%d{dd-MMM}.log.gz">
<PatternLayout pattern="%d{ISO8601} - %m%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingFile>
```

As defined in the properties file, the access logs are collected in {LOG_LOCATION}/access_log.log file. When we load the model server
Expand All @@ -39,16 +39,18 @@ These logs are useful to determine the current performance of the model-server a
## Model Server Logs
These logs collect all the logs from Model Server and from the backend workers (the custom model code).
The default configuration pertaining to mms logs are as follows:
```properties
log4j.logger.com.amazonaws.ml.mms = DEBUG, mms_log


log4j.appender.mms_log = org.apache.log4j.RollingFileAppender
log4j.appender.mms_log.File = ${LOG_LOCATION}/mms_log.log
log4j.appender.mms_log.MaxFileSize = 100MB
log4j.appender.mms_log.MaxBackupIndex = 5
log4j.appender.mms_log.layout = org.apache.log4j.PatternLayout
log4j.appender.mms_log.layout.ConversionPattern = %d{ISO8601} [%-5p] %t %c - %m%n
```xml
<RollingFile
name="mms_log"
fileName="${env:LOG_LOCATION:-logs}/mms_log.log"
filePattern="${env:LOG_LOCATION:-logs}/mms_log.%d{dd-MMM}.log.gz">
<PatternLayout pattern="%d{ISO8601} [%-5p] %t %c - %m%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingFile>
```

This configuration by default dumps all the logs above `DEBUG` level.
Expand All @@ -73,15 +75,14 @@ e...
```

# Modifying the behavior of the logs
In order to modify the default behavior of the logging, you could define `log4j.properties` file. There are two ways of starting
In order to modify the default behavior of the logging, you could define `log4j2.xml` file. There are two ways of starting
model server with custom logs

### Provide with config.properties
Once you define custom `log4j.properties`, add this to the
`config.properties` file as follows
Once you define custom `log4j2.xml`, add this to the `config.properties` file as follows

```properties
vmargs=-Dlog4j.configuration=file:///path/to/custom/log4j.properties
vmargs=-Dlog4j.configurationFile=file:///path/to/custom/log4j2.xml
```
Then start the model server as follows
```bash
Expand All @@ -91,7 +92,7 @@ $ multi-model-server --start --mms-config /path/to/config.properties
Alternatively, you could start the model server with the following command as well

```bash
$ multi-model-server --start --log-config /path/to/custom/log4j.properties
$ multi-model-server --start --log-config /path/to/custom/log4j2.xml
```

# Enable asynchronous logging
Expand Down
10 changes: 2 additions & 8 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Metrics are collected by default at:
* System metrics - log_directory/mms_metrics.log
* Custom metrics - log directory/model_metrics.log

The location of log files and metric files can be configured at [log4j.properties](https://github.com/awslabs/multi-model-server/blob/master/frontend/server/src/main/resources/log4j.properties) file.
The location of log files and metric files can be configured at [log4j2.xml](https://github.com/awslabs/multi-model-server/blob/master/frontend/server/src/main/resources/log4j2.xml) file.


## System Metrics
Expand Down Expand Up @@ -41,13 +41,7 @@ CPUUtilization.Percent:0.0|#Level:Host|#hostname:my_machine_name
MemoryUsed.Megabytes:13840.328125|#Level:Host|#hostname:my_machine_name
```

To enable metric logging in JSON format, we can modify the log formatter in [log4j.properties](https://github.com/awslabs/multi-model-server/blob/master/frontend/server/src/main/resources/log4j.properties), This is explained in the logging [document](https://github.com/awslabs/multi-model-server/blob/master/docs/logging.md).

to enable JSON formatting for metrics change it to

```properties
log4j.appender.mms_metrics.layout = com.amazonaws.ml.mms.util.logging.JSONLayout
```
To enable metric logging in JSON format, we can modify the log formatter in [log4j2.xml](https://github.com/awslabs/multi-model-server/blob/master/frontend/server/src/main/resources/log4j2.xml), This is explained in the logging [document](https://github.com/awslabs/multi-model-server/blob/master/docs/logging.md).

Once enabled the format emitted to logs, will look as follows

Expand Down
2 changes: 1 addition & 1 deletion docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ There are no default required arguments to start the server
c) Multiple models loading are also supported by specifying multiple name path pairs.
1. **model-store**: optional, A location where models are stored by default, all models in this location are loaded, the model name is same as archive or folder name.
1. **mms-config**: optional, provide a [configuration](configuration.md) file in config.properties format.
1. **log-config**: optional, This parameter will override default log4j.properties, present within the server.
1. **log-config**: optional, This parameter will override default log4j2.xml, present within the server.
1. **start**: optional, A more descriptive way to start the server.
1. **stop**: optional, Stop the server if it is already running.
Expand Down
4 changes: 2 additions & 2 deletions mms/model_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def start():
print("--log-config file not found: {}".format(log_config))
exit(1)

cmd.append("-Dlog4j.configuration=file://{}".format(log_config))
cmd.append("-Dlog4j.configurationFile=file://{}".format(log_config))

tmp_dir = os.environ.get("TEMP")
if tmp_dir:
Expand Down Expand Up @@ -110,7 +110,7 @@ def start():
arg_list = vm_args.split()
if args.log_config:
for word in arg_list[:]:
if word.startswith("-Dlog4j.configuration="):
if word.startswith("-Dlog4j.configurationFile="):
arg_list.remove(word)
cmd.extend(arg_list)
plugins = props.get("plugins_path", None)
Expand Down
2 changes: 1 addition & 1 deletion mms/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
This is the current version of MMS
"""

__version__ = '1.1.4'
__version__ = '1.1.5'

0 comments on commit 6524fcf

Please sign in to comment.