# make wpa_supplicant automatically log

## technopenguin

I wanted to debug wpa_supplicant by including a wpa.log file or the like under /var/log.  I know I could do 

wpa_supplicant -f /var/log/wpa.log

once I've logged on, but I wanted to see if I could make the logging start automatically, through configuration of /etc/conf.d/net.  So far, I had

```
wpa_supplicant_wlan0="-f /var/log/wpa.log"
```

which didn't work, among similar variations, like no space between the 'f' and the directory.

I appreciate any help on this.

----------

## khayyam

 *technopenguin wrote:*   

> I wanted to debug wpa_supplicant by including a wpa.log file or the like under /var/log.  I know I could do wpa_supplicant -f /var/log/wpa.log

 

technopenguin ... you need to rebuild with 'debug' use set to get -f<debug file>, otherwise you only have syslog facility. Once this is enabled you will then be able to add "-f /var/log/wpa_supplicant.log" to wpa_supplicant_wlan0= in conf.d/net.

best ... khay

----------

## Logicien

I am not sure if it is necessary to set the debug USE flag to be able to use the -f switch of Wpa_supplicant. The -f switch refer to a log file. Log is not identical to debug. The -d switch refer to the debug verbosity level. That switch could need the debug USE flag to work.

One think that can be done before setting the debug USE flag is to start wpa_supplicant manually in command line with the -f switch activated and if needed in foreground to see if the logs output are write to the log file or shown to stdout when the -B switch is not used. I use Wpa_supplicant with the -f switch with others distributions, and it work as expected.

----------

## khayyam

 *Logicien wrote:*   

> I am not sure if it is necessary to set the debug USE flag to be able to use the -f switch of Wpa_supplicant. The -f switch refer to a log file. Log is not identical to debug.

 

Paul ... well, I am sure ... if I wasn't I would have said something more tentative than "you need [...]" ... and note in the --help "[-f<debug file>]" so it's not "logging" but "debug" ... logging is provided by the syslog facility.

best ... khay

----------

## Logicien

This is what I have in the man wpa_supplicant for the -d and -f switch:

```

man wpa_supplicant

,,,

-d     Increase debugging verbosity (-dd even more).

...

-f output file

              Log output to specified file instead of stdout.

...

The easiest way to debug problems, and to get debug log for bug reports, is  to  start  wpa_supplicant  on  foreground  with  debugging enabled:

              wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d

...

```

Anyway, the debug USE flag can be usefull. It just about precision.

----------

## khayyam

paul ... OK, but the manpage is imprecise in this instance. If you want to test then rebuild with USE="debug" and provide a "-f /var/log/wpa_supplicant.conf" in wpa_supplicant_wlan0= you'll see it works, but with USE="-debug" it won't.

The manpage assumes that 'debugging' is enabled (which is probably the default, and why it 'works' with other distros), with Gentoo this is optional based on USE.

I assure you this is correct ... so yes, precision.

best ... khay

----------

## technopenguin

So, I have

config_wlan0=( "dhcp" )

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dwext"

wpa_supplicant_wlan0=( "-f /var/log/wpa_supplicant.log" )

wpa_supplicant_wlan0=( "-dd" )

I know that last part works, since without the -dd, my /var/log/messages wouldn't have all the extra information.  I was able to make the -f option work when starting wpa from the terminal myself (before, -f would give a usage error).  I looked in the log file, and saw that it was basically everything in the messages file, just separate.  I don't exactly need that separation, just the information, so I won't pursue this further too much, but if there is something I did wrong, and somebody knows what makes it work, I've recompiled so that the debug flag is included.  There must be something to the configuration...

----------

## khayyam

technopenguin ...

wpa_supplicant_wlan0 is a variable, if you define it multiple times then the last will have precidence, hence the '-dd' working but the '-f' not. So ... combine the required options into one variable:

```
wpa_supplicant_wlan0="-Dwext -dd -f /var/log/wpa_supplicant.log"
```

Also the use of =( "foo" ) is depreciated, use ="foo" ..

best ... khay

----------

## technopenguin

This will help with debugging, now that I see the resultant log file.  Thank you, that was extremely helpful!  Many thanks to the both of you for your input and response  :Very Happy: 

----------

