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

Improvement/Support JSON log output #799

Open
blotus opened this issue May 14, 2021 · 5 comments
Open

Improvement/Support JSON log output #799

blotus opened this issue May 14, 2021 · 5 comments
Assignees
Labels
good first issue Good for newcomers kind/enhancement New feature or request needs/triage

Comments

@blotus
Copy link
Member

blotus commented May 14, 2021

We use logrus to handle all of crowdsec logs.
As logrus natively supports a JSON formatter, we should allow users to configure which output format they want (either plaintext or JSON).

@blotus blotus added the kind/enhancement New feature or request label May 14, 2021
@buixor buixor added the good first issue Good for newcomers label Jun 14, 2021
@nanikjava
Copy link
Contributor

@blotus is the log configuration only for crowdsec or including the cli ?

@LaurenceJJones
Copy link
Contributor

@nanikjava To answer your question it would be crowdsec agent itself than the CLI since the cli already support -o json flag

@sharkymcdongles
Copy link

This would be a nice feature to have because structured logging is quite important for a security tool.

@ScreNN
Copy link

ScreNN commented Jun 13, 2023

I support the idea

@victoredvardsson
Copy link
Contributor

This improvement will be added with this one #2941

mmetc added a commit that referenced this issue Dec 23, 2024
* make it possible to enable json log

* fix

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* Add error handling

* Add log_format to default config

* Fix syntax error in if statement

* Fix typo

* Fix typo

* Fix some typos and change naming from native to text, makes more sense

* Set same timestamp format for json logging

* Fix formatting

* Move in if statement under previous

* Fix some formatting that got messed up

* Default to text formatter, if log_format is not configured.

* defining logFormatter outside if statement so that log.SetFormatter(logFormatter) is not undefined when function is called

* Add variables that were undefined

* Argument were missing when calling SetDefaultLoggerConfig function

* Fix order of arguments passed

* Fix order of arguments passed

* Fix typo

* Implicit log_format = "text"

* functional test

* ignore log_format in FatalHook

* make it possible to enable json log

* fix

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* Add error handling

* Add log_format to default config

* Fix syntax error in if statement

* Fix typo

* Fix typo

* Fix some typos and change naming from native to text, makes more sense

* Set same timestamp format for json logging

* Fix formatting

* Move in if statement under previous

* Fix some formatting that got messed up

* Default to text formatter, if log_format is not configured.

* defining logFormatter outside if statement so that log.SetFormatter(logFormatter) is not undefined when function is called

* Add variables that were undefined

* Argument were missing when calling SetDefaultLoggerConfig function

* Fix order of arguments passed

* Fix order of arguments passed

* Fix typo

* Implicit log_format = "text"

* functional test

* ignore log_format in FatalHook

* lint

* fix func test

* lint

* remove < > characters from log

---------

Co-authored-by: Victor Edvardsson <victor.edvardsson@loopia.se>
Co-authored-by: marco <marco@crowdsec.net>
Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/enhancement New feature or request needs/triage
Projects
None yet
Development

No branches or pull requests

8 participants