xbmc.log() not recorded in kodi.log file
#1
Question 
I have recently started developing a service and while it is running fine, I do not manage to get anything recorded in the kodi.log file by calling either print() or xbmc.log().

As a matter of fact, even the addon from Service_add-ons (wiki) has the same behavior : nothing get written in the log. Funny enough, when my addon fails and throws and exception, the exception does get recorded in kodi.log.

It seems that I am missing something obvious, but my searches on this forum nor the API did not lead anywhere.

Does anybody have any idea?

Thank you.

V.
Reply
#2
Enable Debug Log in settings
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
Wink 
(2017-11-24, 22:24)Martijn Wrote: Enable Debug Log in settings
That did the trick, but unfortunately I cannot leave this on forever as it generates an overaly on the screen with debug info.

Nevertheless, your suggestion helped me understand the root cause, thank you very much!

Here is the reason, in case this helps others. The log levels are as follows:
  1. LOGDEBUG
  2. LOGINFO
  3. LOGNOTICE
  4. LOGWARNING
  5. LOGERROR
  6. LOGSEVERE
  7. LOGFATAL
  8. LOGNONE
By default, it seems that xbmc.log("message") will log in log level DEBUG. However, unless you activate the debug mode (or tweak advancedsettings.xml), nothing below LOGNOTICE will be recorded in log files.

In other words, if you want an addon to write something in log files, you need to do (at least) xbmc.log("message",level=xbmc.LOGNOTICE)

It is a bit counterintuitive that by default xbmc.log() uses LOGDEBUG level, I would have expected LOGINFO.

Anyway, problem solved, thank you Martijn!

I'll go and update the Wiki

V.
Reply
#4
(2017-11-25, 00:27)V-Turn Wrote: That did the trick, but unfortunately I cannot leave this on forever as it generates an overaly on the screen with debug info.

if you set the loglevel to '1' in advancedsettings, it'll hide the on-screen overlay
http://kodi.wiki/view/Advancedsettings.xml#loglevel

(2017-11-25, 00:27)V-Turn Wrote: It is a bit counterintuitive that by default xbmc.log() uses LOGDEBUG level, I would have expected LOGINFO.
 

it used to be LOGINFO by default, up until a few years ago.
we changed it to LOGDEBUG for several reasons:
- all the logging done by addons was cluttering the logs so much that devs had a hard time analyzing the log for non-addon related issues
- the size of the logfile could grow real fast if you have a bunch of addons installed and keep kodi running 24/7
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
(2017-11-25, 02:16)ronie Wrote: it used to be LOGINFO by default, up until a few years ago.
we changed it to LOGDEBUG for several reasons:
- all the logging done by addons was cluttering the logs so much that devs had a hard time analyzing the log for non-addon related issues
- the size of the logfile could grow real fast if you have a bunch of addons installed and keep kodi running 24/7 
I see. This makes quite some sense, thank you Ronie!

V.
Reply
#6
(2017-11-25, 00:27)V-Turn Wrote: Here is the reason, in case this helps others. The log levels are as follows:
  1. LOGDEBUG
 

As I have fallen into a problem of log levels today, I allow myself to correct one information for future readers.
It seems that log levels are counted from 0, so that the correct mapping is:
    # 0 = LOGDEBUG
    # 1 = LOGINFO
    # 2 = LOGNOTICE
    # 3 = LOGWARNING
    # 4 = LOGERROR
    # 5 = LOGSEVERE
    # 6 = LOGFATAL
    # 7 = LOGNONE
RPi4; LibreElec
Reply
#7
(2018-02-01, 11:07)bkiziuk Wrote:
(2017-11-25, 00:27)V-Turn Wrote: Here is the reason, in case this helps others. The log levels are as follows:
  1. LOGDEBUG
 

As I have fallen into a problem of log levels today, I allow myself to correct one information for future readers.
It seems that log levels are counted from 0, so that the correct mapping is:
    # 0 = LOGDEBUG
    # 1 = LOGINFO
    # 2 = LOGNOTICE
    # 3 = LOGWARNING
    # 4 = LOGERROR
    # 5 = LOGSEVERE
    # 6 = LOGFATAL
    # 7 = LOGNONE  
 Apologies if my message was misleading, the numbers were actually the bullet autonumbering, not the actual values.

Generally, it is not good practice to hardcode the log level number in your code (so you do not actually care about the actual values behind them), but instead reference xbmc.LOGNOTICE, etc. For example, something like :

xbmc.log(message,xbmc.LOGNOTICE)

Hope that makes sense.

V.
Reply
#8
Yes. I fully agree that hardcoding is not a good practise. I ran into problem of actual values when I started to compare them with a number that I read from addon's settings.
RPi4; LibreElec
Reply
#9
Xbmc.log("yourstring here",2)
Reply

Logout Mark Read Team Forum Stats Members Help
xbmc.log() not recorded in kodi.log file0