Questions tagged [logging]
Computer data logging is the process of recording events in a computer program, usually with a certain scope, in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems.
27 questions
74
votes
9
answers
21k
views
What are some patterns and anti-patterns of application logging? [closed]
I recently had to investigate a field issue for our large enterprise application. I was horrified by the logs that I had to comb through in an attempt to find the problem and at the end of the day the ...
44
votes
11
answers
29k
views
Logging: Why and What? [closed]
I've never written programs which make significant use of logging. The most I've done is to capture stack traces when exceptions happen.
I was wondering, how much do other people log? Does it depend ...
43
votes
2
answers
12k
views
Should You Log From Library Code?
If I am developing a Java library, is it good practice to issue log statements from within the library's code?
Having logging within the library will make debugging and troubleshooting more ...
40
votes
6
answers
36k
views
Try/Catch/Log/Rethrow - Is Anti Pattern?
I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I ...
15
votes
1
answer
11k
views
Log to file or to database table?
I'm developing a web application which uses MS SQL for various data: including users, user accounts, user licenses, license prices, invoices.
I need to log users' real-time usage of the system, and ...
23
votes
6
answers
6k
views
Is logging next to an implementation a SRP violation?
When thinking of agile software development and all the principles (SRP, OCP, ...) I ask myself how to treat logging.
Is logging next to an implementation a SRP violation?
I would say yes because ...
16
votes
5
answers
4k
views
Does the responsibility of logging method/function calls fall to the caller or the callee?
What are the pros and cons to each of the following ways of logging a function call? This code is written in Ruby but I feel the question applies to programming in general.
Responsibility belongs to ...
5
votes
2
answers
484
views
Is ok to leave untranslated advanced log?
I just had a little fight with my boss over this topic (well, the boss always wins so I will do what he wants to be done) but I'd like to have the opinion of others about this:
We are making a ...
4
votes
1
answer
6k
views
How to design a log() method that can easily be accessed from the outside of the Console class?
Recently my team has programmed a custom developer console in a video game which can easily be hidden or displayed, because it's more comfortable and less of a hassle.
The Console class contains a ...
175
votes
3
answers
78k
views
Benefits of Structured Logging vs basic logging
We're building a new app and I'd like to include structured logging. My ideal setup would be something like Serilog for our C# code, and Bunyan for our JS. These would feed into fluentd and then could ...
34
votes
4
answers
71k
views
What is the correct way to handle debug output in Java?
As my current Java projects grow bigger and bigger, I feel a likewise growing need to insert debug output in several points of my code.
To enable or disable this feature appropriately, depending on ...
25
votes
2
answers
6k
views
Logging in JSON Effect on Performance
I see more and more articles about logging in JSON. You can also find one on NodeJS blog. Why does everyone like it so much? I can only see more operations getting involved:
A couple new objects ...
23
votes
5
answers
7k
views
Should I use a global logging variable?
Over and over again we're told, "globals are bad" and with good reason. However, I'm working with a logger that needs to be accessible everywhere in the program. Why shouldn't I create a ...
23
votes
7
answers
67k
views
Best practices for logging user actions in production
I was planning on logging a lot of different stuff in my production environment, things like when a user:
Logs In, Logs Off
Change Profile
Edit Account settings
Change password
...
etc
Is this a ...
18
votes
2
answers
33k
views
Is Logger.getLogger(MyClass.class) the best way to initialise log4j loggers?
This Mkyong tutorial suggests intialising loggers this way:
@Controller
public class WelcomeController {
private static final Logger logger = Logger.getLogger(WelcomeController.class);
// ...
17
votes
4
answers
46k
views
Which design pattern is more suitable for logging?
I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
15
votes
8
answers
9k
views
Is it possible to keep logging code completely outside the business logic?
With the help of AOP, I can remove the logging code from my business logic. But I think it can only be used to log simple things (i.e. logging method entry/exit and parameter values).
However, what ...
15
votes
8
answers
10k
views
Should I log errors on exception throwing constructors?
I was building an application for a few months and I come to realize a pattern that emerged:
logger.error(ERROR_MSG);
throw new Exception(ERROR_MSG);
Or, when catching:
try {
// ...block that ...
14
votes
4
answers
17k
views
Design pattern for wrapping logging around execution
Introduction
I am implementing a abstract Java class of a processing framework*. By implementing the function execute, I am able to add business logical functionality. I would like to add logging at ...
8
votes
2
answers
6k
views
Concurrency pattern of logger in multithreaded application
The context:
We are working on a multi-threaded (Linux-C) application that follows a pipeline model.
Each module has a private thread and encapsulated objects which do processing of data; and each ...
7
votes
4
answers
869
views
Logging errors caused by exceptions deep in the application
What are best-practices for logging deep within an application's source? Is it bad practice to have multiple event log entries for a single error?
For example, let's say that I have an ETL system ...
6
votes
3
answers
399
views
Multitasking how to keep track of what you're doing
I'm in a long debugging task, I need to figure out where to hook up some extra functionality I need.
It's cumbersome work, and I've been debugging 2 whole days, and I'm on my third, but I work in ...
5
votes
4
answers
2k
views
Is it normal to write all logs into a single file?
Our teamlead said that many files much worse than a single, despite of we are working on a big project.
He argued that our customers could more easily send logs to us if there will be just a single ...
3
votes
2
answers
1k
views
Verbose or concise logging [duplicate]
I was wondering how much data should be logged.
I know this deeply depends on multiple factors. But it can still be hard to find the golden middle way.
Lets say I have an application where people ...
2
votes
1
answer
758
views
Design patterns to avoiding breaking the SRP while performing heavy data logging
A class that performs both computations and data logging* seems to have at least two responsibilities. Given a system for which the specifications require heavy data logging, what kind of design ...
1
vote
5
answers
889
views
Making logging more efficient and useful by categorizing data (and virtually not writining messages anymore)
I'd like to make my logs more useful. Currently they mostly contain such common columns as: timestamp, logger-name, log-level, message, exception.
They are unsearchable and unparsable and writing ...
0
votes
2
answers
2k
views
Logging Exception in multi-tier application
I'm building a multi-tier enterprise application using Spring. I have different layers: Controller, Business and Provider. Within the application I've built a custom error handling mini-framework that ...