Change Settings while running, e.g. LogSeverity

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Change Settings while running, e.g. LogSeverity

Postby sjoerd222888 » Tue Nov 08, 2016 10:54 am

Is there a way to change the log level in the CefSettings while the application is running? As far as I understand CefSettings is a startup parameter for CefRuntime.Initiaize.

Is there a way I can change the LogSeverity after calling CefRuntime.Initiaize? I have found this https://bitbucket.org/chromiumembedded/cef/issues/1709/allow-configuration-of-preferences-during, but to me it's yet unclear whether the LogSeverity could also be changed there somehow. E.g. I found no complete list of what is available with CefRequestContext.

But maybe it is unlikely that this is exposed via CefRequestContext. If it was it should more likely be on the global CefRequestContext object.
sjoerd222888
Techie
 
Posts: 15
Joined: Thu Jun 04, 2015 9:02 am

Re: Change Settings while running, e.g. LogSeverity

Postby magreenblatt » Tue Nov 08, 2016 11:14 am

Log severity can only be configured at startup via CefSettings.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Change Settings while running, e.g. LogSeverity

Postby sjoerd222888 » Wed Nov 09, 2016 3:54 am

Thx. That's what I was not sure about.

Do there exist any ideas/concepts of providing your own logger implementation? Or does some approach for this already exist?

If a consumer could provide his own log implementation where he writes the log file himself he could theoretically adopt to log level changes while the application is running. This would also be helpful to integrate Cef logging in the an applications log infrastructure, something I would really appreciate in my case where we are using log4net and such a feature would allow to also use log4net for CefGlue.

Maybe I will open a feature request for this.
sjoerd222888
Techie
 
Posts: 15
Joined: Thu Jun 04, 2015 9:02 am

Re: Change Settings while running, e.g. LogSeverity

Postby fddima » Wed Nov 09, 2016 5:51 am

I'm already do that https://bitbucket.org/chromiumembedded/ ... custom-log but it is never had been implemented by me. From my understanding someone should do this, because this is issue not a critical. Personally i'm like to see this feature, - just now i'm just disable log, but instead want see errors logged with custom logger.

@Marshall, issue marked as duplicate, but no duplicate issue id exists. Looks like this happend errorneously.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Change Settings while running, e.g. LogSeverity

Postby fddima » Wed Nov 09, 2016 6:05 am

BTW, what a use case to vhange log level dynamically?

As i'm see technically log level should be changed dynamically via base/logging.h logging::SetMinLogLevel, but this is probably affects on current process and new child processes.

PS: But it is still be good to have ability to create custom logger - in my case i'm doesnt log into file at all. :)
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Change Settings while running, e.g. LogSeverity

Postby sjoerd222888 » Wed Nov 09, 2016 7:43 am

A use case for changing log level dynamically is the following:

Let's have a complex industrial application. When a customer detects an issue that is reproducible we can ask them to switch the log level to Debug and do again what caused the issue. This helps to get log data of specific operations without the need of restarting the application. For small applications its easy to just restart, but for complex industrial applications it consumes a lot of time to get into the same state again and then of course the user has to remember all the steps he did. Maybe there are multiple ways to end up with the "same information on the screen" but behind the scene the application state might be slightly different. So when the customer calls you, you can just ask him to switch the log level and repeat what he was doing, and so he can do this from the exact application state he currently is in.

I hope you get the idea.

Then you can discuss whether you also want the detailed, maybe Debug level, logs from your third-party libraries you are using and only the log of your application. But in some cases this logs really help. But of course you don't want to run cef with verbose log level all the time.
sjoerd222888
Techie
 
Posts: 15
Joined: Thu Jun 04, 2015 9:02 am

Re: Change Settings while running, e.g. LogSeverity

Postby fddima » Wed Nov 09, 2016 8:08 am

sjoerd222888 wrote:A use case for changing log level dynamically is the following:
Let's have a complex industrial application. When a customer detects an issue that is reproducible we can ask them to switch the log level to Debug and do again what caused the issue. This helps to get log data of specific operations without the need of restarting the application.

Thanks. I'm imagined something similar.
Just for note, that there is can be some log (error) messages raised once at startup, or during browser creation. I.e. with dynamic log severity you potentially can miss something important depending from reproduction cycle.


So i'm aggregate a bit:

1. Allow change log severity dynamically. From chromium implementation i'm doesn't see nothing what should prevent do it, and implementation is trivial. (We need just call logging::SetMinLogLevel).

2. Extend CEF API which allow configure own custom log message handler. This should be useful for route log messages to other logging frameworks. (logging::SetLogMessageHandler and probably logging::SetLogAssertHandler can be useful, also note that if log message handler is configured, then file-based logging are disabled (by base/logging.cc implementation.)

In that case you should not needed to filter messages by severity levels manually (manual filtering is counter-efficient, because all log messages will be virtually written (i.e. formatted, and log handler callback called, but this never happens for suppressed logging calls by severity level).

Questions:

@magreenblatt, do you accept this kind changes for CEF if PR will be provided?

@sjoerd222888, do you will try implement this for CEF?


Add: I'm not sure / not checked, how logging for same file happens for renderer process? Renderer process sends IPC messages or just directly write to file? (I'm think that it is writes to file directly.) Just for note, that this is can be not clear how to deal with it. For example for network logging we need log from both processes, but if we create sandboxed application (not a standard .NET application) - we can't do it (?) from renderer process?
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Change Settings while running, e.g. LogSeverity

Postby magreenblatt » Wed Nov 09, 2016 12:15 pm

fddima wrote:@Marshall, issue marked as duplicate, but no duplicate issue id exists. Looks like this happend errorneously.

Fixed.

fddima wrote:@magreenblatt, do you accept this kind changes for CEF if PR will be provided?

A PR to expose external logging using existing Chromium APIs would be welcome.

SetMinLogLevel is intended to be called during application startup and before the creation of new threads/processes. If you wish to change it dynamically you should first file an issue with Chromium and discuss with the relevant base/OWNERS.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Change Settings while running, e.g. LogSeverity

Postby fddima » Wed Nov 09, 2016 1:21 pm

magreenblatt wrote:SetMinLogLevel is intended to be called during application startup and before the creation of new threads/processes. If you wish to change it dynamically you should first file an issue with Chromium and discuss with the relevant base/OWNERS.

I'm only see that GetMinLogLevel/SetMinLogLevel is simple accessors for global variable. LOG macroses uses ShouldCreateLogMessage to determine that should log by direct access to global variable. So i'm just not see place for wrong usage or any other meanings / intentions. VLOG works bit differently, but fallback to GetMinLogLevel if no vlog info available.
Anyway @sjoerd222888 can ask chrome devs if this is really needed.

Thanks.

UPD: I mean that Get/SetMinLogLevel looks like operates on global logging level, it is not thread-specific. There is no have sense change it before thread creation. Process on other side can consume current logging, but not sure that this is implemented.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Change Settings while running, e.g. LogSeverity

Postby magreenblatt » Wed Nov 09, 2016 2:50 pm

fddima wrote:UPD: I mean that Get/SetMinLogLevel looks like operates on global logging level, it is not thread-specific. There is no have sense change it before thread creation. Process on other side can consume current logging, but not sure that this is implemented.

Changing this global variable during runtime may have consequences that are not immediately obvious. Also, the runtime change will not be communicated to sub-processes without additional plumbing.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 15 guests