# Diverting all console messages from a process



## lemurid (Dec 28, 2011)

I'm running a transmission-daemon with error logging enabled. This gives a lot of records diverted to my console such as 


```
Dec 28 18:59:53 yyy transmission-daemon[36329]: zzzzz No data found! Ensure your drives are connected or use "Set Location".
 To re-download, remove the torrent and re-add it. (torrent.c:487)
```
How can I divert all this messages to a file? I have tried setting up the following record in syslog.conf:


```
!transmission-daemon
*.*                                             /var/log/transmission-remote.log
```
with no success


----------



## SirDice (Dec 28, 2011)

Set *message-level* to 1 or 0 in transmission's settings.json.


----------



## lemurid (Dec 28, 2011)

Well that would have been fine if I didn't want to receive them at all. Anyway I have found that since 1.91 transmission daemon supports logging to a file. The only question left where to put the directives in rc.d script to start the transmission with the following flags?


```
-e --logfile <filename> Dump the log messages to this filename
```

Here is rc.d script attached


```
. /etc/rc.subr

name="transmission"
rcvar=${name}_enable

command=/usr/local/bin/transmission-daemon

load_rc_config ${name}

: ${transmission_enable:="NO"}
: ${transmission_user:="transmission"}
: ${transmission_conf_dir="/usr/local/etc/transmission/home"}
: ${transmission_download_dir="/usr/local/etc/transmission/home/Downloads"}
transmission_flags=" \
        ${transmission_watch_dir:+-c ${transmission_watch_dir}} \
        ${transmission_conf_dir:+-g ${transmission_conf_dir}} \
        ${transmission_download_dir:+-w ${transmission_download_dir}} \
        ${transmission_flags}"

run_rc_command "$1"
```


----------



## wblock@ (Dec 28, 2011)

Don't modify the rc script, set the flags in /etc/rc.conf:

```
transmission_flags="-e --logfile /var/log/transmission.log"
```
Untested.


----------



## aragon (Dec 30, 2011)

I guess they're getting caught by the first line of a default /etc/syslog.conf.  I suggest you add this to /etc/rc.conf:


```
syslogd_flags="-vv"
```

And then restart.  You'll now see the facility and log level of each message syslog generates, which will help you to modify /etc/syslog.conf appropriately.

If my guess is right, you can try add this to the top of your /etc/syslog.conf:


```
!-transmission-daemon
```


----------



## dave (Feb 1, 2012)

*rc.conf correction*



			
				wblock@ said:
			
		

> Don't modify the rc script, set the flags in /etc/rc.conf:
> 
> ```
> transmission_flags="-e --logfile /var/log/transmission.log"
> ...



*Either:*

```
transmission_flags="-e /var/log/transmission.log"
```

*OR:*

```
transmission_flags="--logfile /var/log/transmission.log"
```

*Then...*

```
# touch /var/log/transmission.log
# chown transmission /var/log/transmission.log
# service transmission restart
```

This prevents transmission from writing to the console, unless it runs into big trouble, such as not being able to open the log file or save settings.json.


----------

