Infrastructure/AppBestPractices

From FedoraProject

< Infrastructure(Difference between revisions)
Jump to: navigation, search
(Initial creation of best practices for infra apps)
 
m (Minor tweak to test the mediawiki fedmsg plug)
Line 32: Line 32:
 
</pre>
 
</pre>
 
                                                                                                                                                                      
 
                                                                                                                                                                      
Your app logs will then appear in                                                                                                                                         
+
The app logs will then appear in                                                                                                                                         
 
'''/var/log/hosts/<HOST>/<YEAR>/<MONTH>/<DAY>/apps.log''' as well as the merged log                                                                                             
 
'''/var/log/hosts/<HOST>/<YEAR>/<MONTH>/<DAY>/apps.log''' as well as the merged log                                                                                             
 
'''/var/log/merged/apps.log'''.
 
'''/var/log/merged/apps.log'''.

Revision as of 19:27, 19 January 2013

Best Practices for Fedora Infrastructure Apps

Coding style

Logging to syslog

Most of our apps use the standard Python logging module, which usually ends up logging to /var/log/httpd/error_log on the local machine.

To have your app logs shipped to our central logging server, you can configure the SysLogHandler like so:

[logging]                                                                                                                                                             
                                                                                                                                                                          
[[handlers]]                                                                                                                                                          
                                                                                                                                                                         
[[[syslog_out]]]                                                                                                                                                      
class='handlers.SysLogHandler'                                                                                                                                        
args="('/dev/log', handlers.SysLogHandler.LOG_LOCAL4,)"                                                                                                               
formatter='message_only'                                                                                                                                              
                                                                                                                                                                          
[[loggers]]                                                                                                                                                           
                                                                                                                                                                          
[[[bodhi]]]                                                                                                                                                           
level='DEBUG'                                                                                                                                                         
qualname='bodhi'                                                                                                                                                      
handlers=['syslog_out']                                                                                                                                               
propagate=0                                                                                                                                                           

The app logs will then appear in /var/log/hosts/<HOST>/<YEAR>/<MONTH>/<DAY>/apps.log as well as the merged log /var/log/merged/apps.log.