Repository: bokeh/bokeh

Issue:
Server logger (format, output, etc) does not work
hello

Anyone had luck redirecting the server logs to a file?

Using Bokeh 0.12.6 (latest), I can't seem to be able to use the bokeh logger. 

I tried using the [basicConfig ](http://bokeh.pydata.org/en/latest/docs/reference/util.html#bokeh-util-logconfig)wrapper but id does not seem to work.

```
from bokeh.util import logconfig
logconfig.basicConfig(filename="output.log")
```

I also tried creating another standard logger without using Bokeh (e.g. with logging module), but it does not work either.

Here's a minimal example where I try do directly use the `bokeh_logger` :

```
from bokeh.io import curdoc
from bokeh.util.logconfig import basicConfig, bokeh_logger as bl
import logging

basicConfig(level=logging.DEBUG, filename='output.log')
bl.info('info......')
bl.error('error.......')
bl.warning('Warning.......')

doc = curdoc()
```

Am I missing something? Maybe it's a bug.

Thanks



Discussion:
Seems to be fixed in 0.12.13
Hello! Are your examples working then? They are not working for me for the 0.12.13 version

There are two options when the bokeh server is run from terminal:
```
  --log-level LOG-LEVEL
                        One of: trace, debug, info, warning, error or critical
  --log-format LOG-FORMAT
                        A standard Python logging format string (default:
                        '%(asctime)s %(message)s')
```
I suggest adding a third option to set where to store or send the output:

* `stdout`. Should this be the default value?
* A file path where to store the log file

The basicConfig is [defined here](https://github.com/bokeh/bokeh/blob/master/bokeh/util/logconfig.py). The `stdout` stream could be set like this: 
```
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
```



Resolving patch:
diff --git a/bokeh/command/subcommands/serve.py b/bokeh/command/subcommands/serve.py
--- a/bokeh/command/subcommands/serve.py
+++ b/bokeh/command/subcommands/serve.py
@@ -368,6 +368,13 @@ def _fixup_deprecated_host_args(args):
         default = DEFAULT_LOG_FORMAT,
         help    = "A standard Python logging format string (default: %r)" % DEFAULT_LOG_FORMAT.replace("%", "%%"),
     )),
+
+    ('--log-file', dict(
+        metavar ='LOG-FILE',
+        action  = 'store',
+        default = None,
+        help    = "A filename to write logs to, or None to write to the standard stream (default: None)",
+    )),
 )
 
 class Serve(Subcommand):
@@ -502,7 +509,7 @@ def invoke(self, args):
         applications = build_single_handler_applications(args.files, argvs)
 
         log_level = getattr(logging, args.log_level.upper())
-        basicConfig(level=log_level, format=args.log_format)
+        basicConfig(level=log_level, format=args.log_format, filename=args.log_file)
 
         # This should remain here until --host is removed entirely
         _fixup_deprecated_host_args(args)


Test patch:
diff --git a/bokeh/command/subcommands/tests/test_serve.py b/bokeh/command/subcommands/tests/test_serve.py
--- a/bokeh/command/subcommands/tests/test_serve.py
+++ b/bokeh/command/subcommands/tests/test_serve.py
@@ -65,6 +65,13 @@ def test_args():
             help    = "A standard Python logging format string (default: %r)" % scserve.DEFAULT_LOG_FORMAT.replace("%", "%%"),
         )),
 
+        ('--log-file', dict(
+            metavar ='LOG-FILE',
+            action  = 'store',
+            default = None,
+            help    = "A filename to write logs to, or None to write to the standard stream (default: None)",
+        )),
+
         ('files', dict(
             metavar='DIRECTORY-OR-SCRIPT',
             nargs='*',