Index: trac/env.py
===================================================================
--- trac/env.py	(revision 2946)
+++ trac/env.py	(working copy)
@@ -36,14 +36,14 @@
 
     def environment_needs_upgrade(db):
         """Called when Trac checks whether the environment needs to be upgraded.
-        
+
         Should return `True` if this participant needs an upgrade to be
         performed, `False` otherwise.
         """
 
     def upgrade_environment(db):
         """Actually perform an environment upgrade.
-        
+
         Implementations of this method should not commit any database
         transactions. This is done implicitly after all participants have
         performed the upgrades they need without an error being raised.
@@ -59,12 +59,12 @@
      * an SQLite database (stores tickets, wiki pages...)
      * Project specific templates and wiki macros.
      * wiki and ticket attachments.
-    """   
+    """
     setup_participants = ExtensionPoint(IEnvironmentSetupParticipant)
 
     def __init__(self, path, create=False, options=[]):
         """Initialize the Trac environment.
-        
+
         @param path:   the absolute path to the Trac environment
         @param create: if `True`, the environment is created and populated with
                        default data; otherwise, the environment is expected to
@@ -76,23 +76,24 @@
 
         self.path = path
         self.load_config()
-        self.setup_log() 
 
-        from trac.loader import load_components
-        load_components(self)
-
         if create:
+            self.setup_log(True)
             self.create(options)
         else:
+            self.setup_log()
             self.verify()
 
+        from trac.loader import load_components
+        load_components(self)
+
         if create:
             for setup_participant in self.setup_participants:
                 setup_participant.environment_created()
 
     def component_activated(self, component):
         """Initialize additional member variables for components.
-        
+
         Every component activated through the `Environment` object gets three
         member variables: `env` (the environment object), `config` (the
         environment configuration) and `log` (a logger object)."""
@@ -103,7 +104,7 @@
     def is_component_enabled(self, cls):
         """Implemented to only allow activation of components that are not
         disabled in the configuration.
-        
+
         This is called by the `ComponentManager` base class when a component is
         about to be activated. If this method returns false, the component does
         not get activated."""
@@ -146,7 +147,7 @@
     def get_repository(self, authname=None):
         """Return the version control repository configured for this
         environment.
-        
+
         @param authname: user name for authorization
         """
         repos_type = self.config.get('trac', 'repository_type')
@@ -218,7 +219,7 @@
         """Return absolute path to the log directory."""
         return os.path.join(self.path, 'log')
 
-    def setup_log(self):
+    def setup_log(self, create=False):
         """Initialize the logging sub-system."""
         from trac.log import logger_factory
         logtype = self.config.get('logging', 'log_type')
@@ -227,7 +228,10 @@
         if not os.path.isabs(logfile):
             logfile = os.path.join(self.get_log_dir(), logfile)
         logid = self.path # Env-path provides process-unique ID
-        self.log = logger_factory(logtype, logfile, loglevel, logid)
+        if create:
+            self.log = logger_factory('syslog', logfile, loglevel, logid)
+        else:
+            self.log = logger_factory(logtype, logfile, loglevel, logid)
 
     def get_known_users(self, cnx=None):
         """Generator that yields information about all known users, i.e. users
@@ -281,7 +285,7 @@
 
     def upgrade(self, backup=False, backup_dest=None):
         """Upgrade database.
-        
+
         Each db version should have its own upgrade module, names
         upgrades/dbN.py, where 'N' is the version number (int).
 

