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

Having logs printed on console with a different formatting and additional content but that should not affect the logs in file. #1082

Open
AvinashPrasad12345 opened this issue Feb 14, 2024 · 6 comments
Labels
question Further information is requested

Comments

@AvinashPrasad12345
Copy link

I am working on a project where i have to implement loguru at every juncture, to do that i have been asked to store the logs in a specific file in syslog rfc5424 format, i am able to do that successfully till now, but now i have been tasked with printing logs on console as well but their format should be different and some additional content needs to be present on the console, and the console logs format should not affect the format of logs in the file which are in syslog format.

I tried using bind() method but that is not helping me out, every single time i run the code but it adds the additional info to the file as well which i dont want, how to fix this?

@Delgan please help me out

@Delgan Delgan added the question Further information is requested label Feb 17, 2024
@Delgan
Copy link
Owner

Delgan commented Feb 17, 2024

@AvinashPrasad12345 Do you have a more concrete example please?

You can configure two different handlers with two different formats:

logger.add("file.log", format="{time} {level} {message}")
logger.add(sys.stderr, format="{time} {level} {extra} {message}")

@AvinashPrasad12345
Copy link
Author

@AvinashPrasad12345 Do you have a more concrete example please?

You can configure two different handlers with two different formats:

logger.add("file.log", format="{time} {level} {message}")
logger.add(sys.stderr, format="{time} {level} {extra} {message}")

Hey!, well thanks a ton and yes the issue was resolved, gratified for the assitance

@AvinashPrasad12345
Copy link
Author

actually this is a huge project i am working on, right now I have been tasked with sending these logs created using loguru to opentelemetry collector, how is that done?

please help @Delgan

@Delgan
Copy link
Owner

Delgan commented Feb 20, 2024

For integration with OpenTelemetry, you can take a look at this thread: #674 (comment)

@AvinashPrasad12345
Copy link
Author

For integration with OpenTelemetry, you can take a look at this thread: #674 (comment)

Thank you for the clarification, using this methodology, shall i be able to view my logs on opentelemetry collector? along with traces?

@Delgan
Copy link
Owner

Delgan commented Feb 21, 2024

Not being an OpenTelemetry user myself, I can't confirm that with certitude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants