154 | | You need to turn on logging in the trac.ini file. Info level log is not as often as debug level. Thus it is very good way to debug the plug-in code. However, you should use debug method if you want to leave the code when you finish developing the plug-in. |
| 156 | If you are inside the methods of a `Component` subclass, better use: |
| 157 | {{{ |
| 158 | #!python |
| 159 | self.log.debug("Hey, varname is %r", varname) |
| 160 | }}} |
| 161 | This will implicitly use the `self.env` Environment, but your component name will now be used for the $module (see TracLogging#LogFormat). This makes it easier to identify the relevant debug lines. |
| 162 | |
| 163 | Note that there's no way to log something at the global level, outside the scope of a Trac environment, as the configuration of logging is done at that level and usually the log file is located in `$tracenv/log/trac.log`. |