GitLab is transitioning from unstructured/plaintext logs to structured/JSON logs. During this transition period some logs will be recorded in multiple formats through multi-destination logging.
### How to use multi-destination logging
Create a new logger class, inheriting from `MultiDestinationLogger` and add an array of loggers to a `LOGGERS` constant. The loggers should be classes that descend from `Gitlab::Logger`. e.g. the user defined loggers in the following examples, could be inheriting from `Gitlab::Logger` and `Gitlab::JsonLogger`, respectively.
You must specify one of the loggers as the `primary_logger`. The `primary_logger` will be used when information about this multi-destination logger is displayed in the app, e.g. using the `Gitlab::Logger.read_latest` method.
The following example sets one of the defined `LOGGERS` as a `primary_logger`.
FancyMultiLogger.info({:message=>"This is my message",:project_id=>123})
# UnstructuredLogger
I,[2020-01-13T12:06:09.856766#8049] INFO -- : {:message=>"This is my message", :project_id=>123}
# StructuredLogger
{:severity=>"INFO",:time=>"2020-01-13T11:06:09.851Z",:correlation_id=>"d7e0886f096db9a8526a4f89da0e45f6",:message=>"This is my message",:project_id=>123}
```
## Exception Handling
It often happens that you catch the exception and want to track it.