Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log file splitting is not working #11269

Closed
2 of 7 tasks
xoxys opened this issue May 1, 2020 · 7 comments
Closed
2 of 7 tasks

Log file splitting is not working #11269

xoxys opened this issue May 1, 2020 · 7 comments
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@xoxys
Copy link
Contributor

xoxys commented May 1, 2020

  • Gitea version (or commit ref): 1.11.4
  • Git version:
  • Operating system: CentOS 7
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

I've set the following options in the custom config file which should enable logging to multiple log files:

ROOT_PATH = /opt/gitea/log
MODE = file
REDIRECT_MACARON_LOG = true
MACARON = file
ROUTER_LOG_LEVEL = Info
ROUTER = file
ENABLE_ACCESS_LOG = true
ACCESS = file
LEVEL = Warn
STACKTRACE_LEVEL = None

But this will still result in empty log files for access, macaron and router:

total 624K
-rw-r-----. 1 gitea gitea    0 Feb 16 16:56 access.log
-rw-r-----. 1 gitea gitea 619K May  1 17:04 gitea.log
-rw-r-----. 1 gitea gitea    0 Feb 16 16:56 macaron.log
-rw-r-----. 1 gitea gitea    0 Feb 16 16:56 router.log
@xoxys xoxys changed the title Log splitting is not working Log file splitting is not working May 1, 2020
@guillep2k
Copy link
Member

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.

@guillep2k guillep2k added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label May 3, 2020
@xoxys
Copy link
Contributor Author

xoxys commented May 3, 2020

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?

@guillep2k
Copy link
Member

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.

@xoxys
Copy link
Contributor Author

xoxys commented May 4, 2020

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.

@zeripath
Copy link
Contributor

zeripath commented May 4, 2020

@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].

@xoxys
Copy link
Contributor Author

xoxys commented May 5, 2020

🤦 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.

@guillep2k
Copy link
Member

Closing as answered. 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

No branches or pull requests

3 participants