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 Level not being determined when expected #3516

Closed
JamesGit1 opened this issue Jan 7, 2025 · 2 comments
Closed

Log Level not being determined when expected #3516

JamesGit1 opened this issue Jan 7, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@JamesGit1
Copy link
Contributor

Describe the feature you would like to see

I've been using Dozzle to view the logs of my (primarily Spring Boot) docker containers locally which works well and looks great 😄. The only thing that has been bugging me is that the log levels are not being picked up properly for the Spring Boot containers and hence filtering by log level.

Logs of container running in v8.10.0
logsWithDozzleV8 10 0

I did a bit of digging and it looks like its because of the guessLogLevel() function in level_guesser.go returning unknown. This is because the logger we are using has the loglevel printed as LL="". I know this may be a fairly untypical logger but I was wondering if there is a possibility of handling this sort of case? Something like the NEW if below?

       func guessLogLevel(logEvent *LogEvent) string {
	switch value := logEvent.Message.(type) {
	case string:
		value = stripANSI(value)
		value = timestampRegex.ReplaceAllString(value, "")
		for _, levelGroup := range logLevels {
			first := levelGroup[0]
			// Look for the level at the beginning of the message
			for _, regex := range plainLevels[first] {
				if regex.MatchString(value) {
					return first
				}
			}

                       // NEW: Look for the level in the middle of the message that are uppercase and surrounded by quotes
	               if strings.Contains(value, "\""+strings.ToUpper(first)+"\"") {
		               return first
	               }
...

I have built the app myself and run and it fixes my problem:
logsWithDozzleWithFix

I don't know much about Go or this app so don't know if this would have any wider effect but I'd be grateful if there was some change made. Thank you !

Describe how you would like to see this feature implemented

A solution like the proposed code would be ideal or some other regex that would match this criteria. Or even some mechanism that allows configuration of the what the log-level is surrounded by. i.e. empty space or double quotes etc

Describe any alternatives you've considered

Have thought about changing the logger but I'm not really at liberty to do that and there might be a solution that helps more people than just me.

@JamesGit1 JamesGit1 added the enhancement New feature or request label Jan 7, 2025
@amir20
Copy link
Owner

amir20 commented Jan 7, 2025

I would be fine with that if you want to send PR. Just add some test cases.

@JamesGit1
Copy link
Contributor Author

Ok I will look into making a PR and writing some test cases when I get a chance, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants