Starting the samba4 daemon with -l do not influence the place where logs are stored. I turns out that the variable logfile is filled with the parameter value when the command line is parsed but after calling lp_file_list_changed in source4/param/loadparm.c, the value is lost.
Any news on this ?
Matthieu, I tried to trace the problem in the source code, but didn't come further. If it's possible for you, please investigate this a bit further and provide more detailed code locations (file/line numbers). Also a patch would be welcome if you manage to write one.
The behaviour is as follows: The log output is always STDOUT until the basic settings were read in. Then, in server.c before the message "samba 4 version X started" the function setup_logging (always function "binary_smbd_main") is called. If you run "samba" in the interactive mode, it remains STDOUT. But if you run it as a daemon, the log is written in a predefined place (in my case /usr/local/samba/var/samba.log"). The problem left to fix is the ignored "-l" parameter. I'm looking into this.
Bug fixed. Now s4 creates a file "log.samba" under the directory you specified with "-l". If the parameter isn't specified at all the default log location will be "var/samba.log". And all the logging through files works only in the daemon mode, never in the interactive one as stated in the previous comment.