Search code examples
linuxloggingdebiangnu-screen

How do I set the name of the log file in `screen`?


Is it possible to set the name of the screen log file? Normally it's called screenlog.n, but I need to know the exact name of a log for a script that I'm writing. I hope somebody can help me. I didn't find anything in the man page for screen!


Solution

  • While you are in screen, enter command mode (Ctrl+A) and use the :logfile command:

    Command: logfile filename
    Command: logfile flush secs

    Defines the name the log files will get. The default is screenlog.%n. The second form changes the number of seconds screen will wait before flushing the logfile buffer to the file-system. The default value is 10 seconds.

    Logging is turned off by default, so to turn it on, use the command :log on to enable logging.

    Command: log [state]

    Begins/ends logging of the current window to the file screenlog.n in the window's default directory, where n is the number of the current window. This filename can be changed with the logfile command. If no parameter is given, the logging state is toggled. The session log is appended to the previous contents of the file if it already exists. The current contents and the contents of the scrollback history are not included in the session log. Default is off.

    Source: https://www.gnu.org/software/screen/manual/html_node/Log.html