mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
Pause, Resume, Release&Reopen, Add and Remove Logging from command line (#11777)
* Make LogDescriptions race safe * Add manager commands for pausing, resuming, adding and removing loggers Signed-off-by: Andrew Thornton <art27@cantab.net> * Placate lint * Ensure that file logger is run! * Add support for smtp and conn Signed-off-by: Andrew Thornton <art27@cantab.net> * Add release-and-reopen Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
38fb087d19
commit
c5b08f6d5a
17 changed files with 924 additions and 17 deletions
|
@ -316,6 +316,28 @@ COLORIZE = true # Or false if your windows terminal cannot color
|
|||
|
||||
This is equivalent to sending all logs to the console, with default go log being sent to the console log too.
|
||||
|
||||
## Releasing-and-Reopening, Pausing and Resuming logging
|
||||
|
||||
If you are running on Unix you may wish to release-and-reopen logs in order to use `logrotate` or other tools.
|
||||
It is possible force gitea to release and reopen it's logging files and connections by sending `SIGUSR1` to the
|
||||
running process, or running `gitea manager logging release-and-reopen`.
|
||||
|
||||
Alternatively, you may wish to pause and resume logging - this can be accomplished through the use of the
|
||||
`gitea manager logging pause` and `gitea manager logging resume` commands. Please note that whilst logging
|
||||
is paused log events below INFO level will not be stored and only a limited number of events will be stored.
|
||||
Logging may block, albeit temporarily, slowing gitea considerably whilst paused - therefore it is
|
||||
recommended that pausing only done for a very short period of time.
|
||||
|
||||
## Adding and removing logging whilst Gitea is running
|
||||
|
||||
It is possible to add and remove logging whilst Gitea is running using the `gitea manager logging add` and `remove` subcommands.
|
||||
This functionality can only adjust running log systems and cannot be used to start the access, macaron or router loggers if they
|
||||
were not already initialised. If you wish to start these systems you are advised to adjust the app.ini and (gracefully) restart
|
||||
the Gitea service.
|
||||
|
||||
The main intention of these commands is to easily add a temporary logger to investigate problems on running systems where a restart
|
||||
may cause the issue to disappear.
|
||||
|
||||
## Log colorization
|
||||
|
||||
Logs to the console will be colorized by default when not running on
|
||||
|
|
|
@ -318,3 +318,85 @@ var checklist = []check{
|
|||
```
|
||||
|
||||
This function will receive a command line context and return a list of details about the problems or error.
|
||||
|
||||
#### manager
|
||||
|
||||
Manage running server operations:
|
||||
|
||||
- Commands:
|
||||
- `shutdown`: Gracefully shutdown the running process
|
||||
- `restart`: Gracefully restart the running process - (not implemented for windows servers)
|
||||
- `flush-queues`: Flush queues in the running process
|
||||
- Options:
|
||||
- `--timeout value`: Timeout for the flushing process (default: 1m0s)
|
||||
- `--non-blocking`: Set to true to not wait for flush to complete before returning
|
||||
- `logging`: Adjust logging commands
|
||||
- Commands:
|
||||
- `pause`: Pause logging
|
||||
- Notes:
|
||||
- The logging level will be raised to INFO temporarily if it is below this level.
|
||||
- Gitea will buffer logs up to a certain point and will drop them after that point.
|
||||
- `resume`: Resume logging
|
||||
- `release-and-reopen`: Cause Gitea to release and re-open files and connections used for logging (Equivalent to sending SIGUSR1 to Gitea.)
|
||||
- `remove name`: Remove the named logger
|
||||
- Options:
|
||||
- `--group group`, `-g group`: Set the group to remove the sublogger from. (defaults to `default`)
|
||||
- `add`: Add a logger
|
||||
- Commands:
|
||||
- `console`: Add a console logger
|
||||
- Options:
|
||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
||||
- `--level value`, `-l value`: Logging level for the new logger
|
||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
||||
- `--flags value`, `-F value`: Flags for the logger
|
||||
- `--expression value`, `-e value`: Matching expression for the logger
|
||||
- `--prefix value`, `-p value`: Prefix for the logger
|
||||
- `--color`: Use color in the logs
|
||||
- `--stderr`: Output console logs to stderr - only relevant for console
|
||||
- `file`: Add a file logger
|
||||
- Options:
|
||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
||||
- `--level value`, `-l value`: Logging level for the new logger
|
||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
||||
- `--flags value`, `-F value`: Flags for the logger
|
||||
- `--expression value`, `-e value`: Matching expression for the logger
|
||||
- `--prefix value`, `-p value`: Prefix for the logger
|
||||
- `--color`: Use color in the logs
|
||||
- `--filename value`, `-f value`: Filename for the logger -
|
||||
- `--rotate`, `-r`: Rotate logs
|
||||
- `--max-size value`, `-s value`: Maximum size in bytes before rotation
|
||||
- `--daily`, `-d`: Rotate logs daily
|
||||
- `--max-days value`, `-D value`: Maximum number of daily logs to keep
|
||||
- `--compress`, `-z`: Compress rotated logs
|
||||
- `--compression-level value`, `-Z value`: Compression level to use
|
||||
- `conn`: Add a network connection logger
|
||||
- Options:
|
||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
||||
- `--level value`, `-l value`: Logging level for the new logger
|
||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
||||
- `--flags value`, `-F value`: Flags for the logger
|
||||
- `--expression value`, `-e value`: Matching expression for the logger
|
||||
- `--prefix value`, `-p value`: Prefix for the logger
|
||||
- `--color`: Use color in the logs
|
||||
- `--reconnect-on-message`, `-R`: Reconnect to host for every message
|
||||
- `--reconnect`, `-r`: Reconnect to host when connection is dropped
|
||||
- `--protocol value`, `-P value`: Set protocol to use: tcp, unix, or udp (defaults to tcp)
|
||||
- `--address value`, `-a value`: Host address and port to connect to (defaults to :7020)
|
||||
- `smtp`: Add an SMTP logger
|
||||
- Options:
|
||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
||||
- `--level value`, `-l value`: Logging level for the new logger
|
||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
||||
- `--flags value`, `-F value`: Flags for the logger
|
||||
- `--expression value`, `-e value`: Matching expression for the logger
|
||||
- `--prefix value`, `-p value`: Prefix for the logger
|
||||
- `--color`: Use color in the logs
|
||||
- `--username value`, `-u value`: Mail server username
|
||||
- `--password value`, `-P value`: Mail server password
|
||||
- `--host value`, `-H value`: Mail server host (defaults to: 127.0.0.1:25)
|
||||
- `--send-to value`, `-s value`: Email address(es) to send to
|
||||
- `--subject value`, `-S value`: Subject header of sent emails
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue