Closed xoxys closed 4 years ago
It's more like:
[log]
MODE = console,file
MAX_DAYS = 15
LEVEL = Info
ROUTER = console,file
XORM = file, console
REDIRECT_MACARON_LOG = true
[log.file.xorm]
FILE_NAME = xorm.log
[log.console]
LEVEL = Fatal
[log.file]
LEVEL = Info
[log.file.router]
LEVEL = Info
FILE_NAME = router.log
[log.console.router]
LEVEL = Fatal
etc.
Hmm ok I'll give it a try but I'm still confused a bit. I found the log documentation https://docs.gitea.io/en-us/logging-configuration/ and it is talking about [log.sublogger]
sections, so what's the right syntax?
Beside that, there should be some default for the sublogger configs like [file.router]
right? So why do I need to set a log level for e.g. [log.file.router]
to get it working? As you can see in my example, I've enabled the router log redirect and gitea creates already a router.log file in my log folder but it's empty. From my understanding it should just work with my provided config snippet.
If this is not enough then my question is, what option exactly is required to get a working standalone router log?
So why do I need to set a log level for e.g. [log.file.router] to get it working?
Sorry if that was not helpful, I just copied&pasted part of my own config and edited it a bit. Of course there are defaults, but I thought I could show you a sample of how is the log configuration structured.
TBH, I'm not an expert on the log configuration. It is a bit confusing because it's been revamped (as of 1.9.something I believe?) with a much more powerful syntax, but it was decided that the new code should support the old syntax too so... your settings happen to resemble the old syntax.
No thanks a lot for your help! :)
I just try to understand the details. Of course the new syntax looks very powerful but currently there are too many questios in my mind :)
I'll play a bit with the config and maybe we could improve the documentation.
@xoxys sorry it's taken me so long to reply.
The macaron, router and access loggers make their entries at INFO level - so setting LEVEL= Warn means that unless you override their specific log level to LEVEL=Info you won't get any.
So the simplest log settings to set what you want should be:
[log]
ROOT_PATH = /opt/gitea/log
MODE = file
REDIRECT_MACARON_LOG = true
MACARON = file
; ROUTER_LOG_LEVEL = Info ; this is the default anyway
ROUTER = file
ENABLE_ACCESS_LOG = true
ACCESS = file
LEVEL = Warn
;STACKTRACE_LEVEL = None ; this is the default anyway
[log.file.macaron]
LEVEL = Info
[log.file.router]
LEVEL = Info
[log.file.access]
LEVEL = Info
Now that's a little awkward and it would probably be nice to set the default logger separately.
So I'll put up a PR that allows us to set [log.file.default]
, separate from [log.file]
.
:facepalm: ouch... ok the log level was the missing part. Makes sense now :) Thanks a lot!
@xoxys sorry it's taken me so long to reply
No need to apologize for anything. All of you do an amazing job. Thanks for your work.
Closing as answered. 😄
[x]
):Description
I've set the following options in the custom config file which should enable logging to multiple log files:
But this will still result in empty log files for access, macaron and router: