mirror of
https://github.com/meganz/MEGAcmd
synced 2025-08-22 01:47:24 +00:00
Add documentation for configuring the rotating logger
This commit is contained in:
parent
981c9f566f
commit
6352251718
@ -57,3 +57,29 @@ In general, as we've mentioned before, lower verbosity log messages are not prin
|
||||
|
||||
## JSON logs
|
||||
When the log level of the SDK is `VERBOSE`, the entire JSON payload of the HTTP requests sent and received from the API will be logged. This takes up a bit more space but provides more valuable info. Full JSON logging can be overwritten independently by setting the environment variable `MEGACMD_JSON_LOGS` to `0` or `1`.
|
||||
|
||||
## Configuring the Rotating Logger
|
||||
The MEGAcmd logger rotates and compresses log files to avoid taking up too much space. Some of its values can be configured to fit the needs of specific systems. These are:
|
||||
* `RotationType`: The type of rotation to use. Possible values are _Timestamp_ and _Numbered_. Defaults to _Timestamp_.
|
||||
* Numbered rotation will add a "file number" suffix when rotating files, keeping track of the total number and removing them if there are more than `MaxFilesToKeep`.
|
||||
* Timestamp rotation will keep track of the total number (similarly to above), while also keeping track of the creation date of files, removing them if they're older than `MaxFileAge`.
|
||||
* `CompressionType`: The type of compression to use. Possible values are _Gzip_ and _None_ (which disables compression). Defaults to _Gzip_.
|
||||
* `MaxFileMB`: The maximum size the `megacmdserver.log` file can be, in megabytes. If it gets over this size, it'll be renamed and compressed according to the rules stated above. Default is usually 50 MB, but will be less for disks with limited space.
|
||||
* `MaxFilesToKeep`: The maximum amount of rotated files allowed. When the total file count exceeds this value, older files will be removed. Default depends on `MaxFileMB`, the compression used, and the system specs.
|
||||
* `MaxFileAgeSeconds`: The maximum age the rotated files can be before being deleted, in seconds. Defaults to 1 month. _Note_: Only used by timestamp-based rotation.
|
||||
* `MaxMessageBusMB`: The maximum memory allowed by the logger's internal bus, in megabytes. Defaults to 512 MB. In most cases, the logger will use way less RAM; it is recommended to check memory usage before changing this value.
|
||||
|
||||
To configure them we must manually edit the `megacmd.cfg` file. This file must be present in the same directory as the `megacmdserver.log` file; if not, we can manually create it. The following is an example of the syntax of this file:
|
||||
```
|
||||
RotatingLogger:RotationType=Timestamp
|
||||
RotatingLogger:CompressionType=None
|
||||
RotatingLogger:MaxFileMB=40.25
|
||||
RotatingLogger:MaxFilesToKeep=20
|
||||
RotatingLogger:MaxFileAgeSeconds=3600
|
||||
RotatingLogger:MaxMessageBusMB=64.0
|
||||
```
|
||||
Values not present in it will be set to their default. Invalid values (such as negative sizes) will be silently discarded. Note that this configuration is only loaded at the start, so the MEGAcmd server must be restarted after adding or changing any of the values.
|
||||
|
||||
Configuring the Rotating Logger might result in previous log files not being rotated or deleted properly. It is recommended to delete them manually (or moving them somewhere else, if we want to preserve them) before changing the configuration.
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user