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

Configuration via INI file #47

Open
fastbike opened this issue Jan 20, 2021 · 3 comments
Open

Configuration via INI file #47

fastbike opened this issue Jan 20, 2021 · 3 comments
Assignees

Comments

@fastbike
Copy link
Contributor

Some of the other logging frameworks I've previously used allow configuration at run time via INI configuration file settings. E.g. something like Log4D based on the Log4J / Log4Net code bases.

It is really useful when you hit a production issue and wish to increase the verbosity of logging from just Error through to Debug level.

Can this be done easily in LoggerPro ?

@danieleteti
Copy link
Owner

Yes, it isn't difficult to do. Can you describe what would be good in your case?

@danieleteti
Copy link
Owner

Now that dmvcframework got dotEnv support this could be done very easily.
Any news about your needs?

@fastbike
Copy link
Contributor Author

fastbike commented Aug 8, 2024

I've come back to this ticket as we are looking to dynamically be able to change the log level while a program is operating.
The use case is - "LogLevel is normally Warning (so web app logs out errors and warnings), but if we have a report of a production issue we want to set it to Debug while the issue is investigated".

It is possible to iterate through the appenders and set the log level on each of these. However that has no effect because the TCustomLogWriter class has a private property "FLogLevel which is compared each time the application wants to log.

procedure TCustomLogWriter.Log(const aType: TLogType; const aMessage, aTag: string);
var
  lLogItem: TLogItem;
begin
  if aType >= FLogLevel then
  begin
// you won't get to this line if the initial setting was warning and now you want debug

I can think of a number of ways to fix this:

  • add a GetLogLevel and SetLogLevel pair of methods to the ICustomLogWriter interface
  • add a GetLogLevel and SetLogLevel pair of methods to the ILogWriter interface
  • add a GetLogLevel and SetLogLevel pair of methods to a new interface and include this into the TCustomLogWriter descendant. This would required the underlying field to be protected rather than strict private.

The BuildLogWriter may also want another overloaded version that optionally takes the class type (TCustomLogWriterClass) so a custom log writer can be instantiated, otherwise the application could re implement a copy of this helper method.

@danieleteti Do you have a preference or should I do a proof of concept and create a PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants