# how to stop the log messages printed to character console?

## double_crane

my laptop has a nvidia GTX765M video card which support nvidia optimus 。

I installed nvidia offical driver whose package name is nvidia-drivers and bumblebee。

and it works well。

but bumblee has a not-compatible bug with nvidia-drivers , about  the video RAM configuration which nvidia offical driver defines ( I know this from bumblebee offical website and some other forums).

bumblee says it will solve this bug in version 4 (now 3.21).

the problem is , this bug is always printing WARNINGs to the character terminal (ctrl + alt + F1-F6) , from boot  to halt.

every 3-5 seconds , it print 

```

[ 12.910565] ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150410/nsarguments-95)

[ 12.950770] ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150410/nsarguments-95)

[ 13.079137] ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150410/nsarguments-95)

[ 15.909104] ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150410/nsarguments-95)

```

just the same with `dmesg` command prints

the character terminal is not able to use. I'm not able to distinguish what command have I inputed .

is there any solution ,to make WARNINGs or INFOs just like above  ,print to /dev/null or other place,but not terminal console ?Last edited by double_crane on Thu Dec 31, 2015 4:28 pm; edited 2 times in total

----------

## khayyam

 *double_crane wrote:*   

> is there any solution to make WARNINGs or INFOs just like above print to /dev/null or other place, but not terminal console?

 

double_crane ... what system logger is in use, and is it running? Sounds as though it isn't.

best ... khay

----------

## double_crane

 *khayyam wrote:*   

>  *double_crane wrote:*   is there any solution to make WARNINGs or INFOs just like above print to /dev/null or other place, but not terminal console? 
> 
> double_crane ... what system logger is in use, and is it running? Sounds as though it isn't.
> 
> best ... khay

 

I use syslog-ng, it is recommended by gentoo offical stage3 installation handbook.

I'm not sure whether I enable it at boot time.I will check it out after back home.

sometimes I disable the log service because the /var/log/messages file is too large ...  

do you mean that if I enable the syslog service , then the WARNINGs will be printed to /var/log/messages , instead of being printed to character console ? 

thank you, I'll try .

-----------------------------------------------------------------------------------------

UPDATE

-----------------------------------------------------------------------------------------

actually , the syslog-ng service is active from boot.

the bug WARNING messages are printed to /var/log/messages as well as character console.Last edited by double_crane on Wed Dec 30, 2015 1:43 pm; edited 1 time in total

----------

## khayyam

 *double_crane wrote:*   

> sometimes I disable the log service because the /var/log/messages file is too large

 

double_crane ... you can use app-admin/logrotate and so have messages (and other log files) truncated to a manageable size/number.

 *double_crane wrote:*   

> do you mean that if I enable the syslog service , then the WARNINGs will be printed to /var/log/messages, instead of being printed to character console?

 

That depends on how the logger is configured, but yes, you could configure for only 'emergency' level messages to be logged to console, and for 'info' and 'warn' to go to /var/log/messages only.

I suspect in your case syslog-ng isn't running.

best ... khay

----------

## double_crane

 *khayyam wrote:*   

>  *double_crane wrote:*   sometimes I disable the log service because the /var/log/messages file is too large 
> 
> double_crane ... you can use app-admin/logrotate and so have messages (and other log files) truncated to a manageable size/number.
> 
>  *double_crane wrote:*   do you mean that if I enable the syslog service , then the WARNINGs will be printed to /var/log/messages, instead of being printed to character console? 
> ...

 

I do enable the syslog-ng from boot time. and the service is running correctly and I can see the WARNING in /var/log/messages . as well as in character terminal.

except changing the emergency level , is there any way to filter the messages more carefully , that only filter these WARNING messages (wich satisfy regular expression like “Gentoo kernel: ACPI Warning”  ?) but not other WARNING messages which are printed only one time ?

or how can I make all messages (including WARNING ERROR INFO... all LEVEL 1-7) not  be printed to console ? all messages printed to /var/log/messages ?

thank youLast edited by double_crane on Thu Dec 31, 2015 2:51 am; edited 1 time in total

----------

## Syl20

 *double_crane wrote:*   

> except changing the emergency level , is there any way to filter the messages more carefully , that only filter these WARNING messages (wich satisfy regular expression like “Gentoo kernel: ACPI Warning”  ?) but not other WARNING messages which are printed only one time ?
> 
> or how can I make all messages not  be printed to console ? all messages printed to /var/log/messages ?

 

Syslog-ng is very (very) (very) powerful, as you can read here. But it needs some time to understand how to properly configure it.

For exemple, to send all but your ACPI messages to /var/log/messages (didn't tested, you may have to tune the filter content) :

```
source s_devlog {                                                                      

        unix-stream("/dev/log" max-connections(20));                                   

        internal();                                                                    

        file("/proc/kmsg");                                                            

};                                                                                     

destination t_messages         { file("/var/log/messages"); };

filter fm_no_acpi              { not message("^.*Gentoo kernel: ACPI Warning.*"); }

log {   source(s_devlog);                                                              

        filter(fm_no_acpi);                                                          

        destination(t_messages);                                                        

};   
```

Have a look on your syslog-ng.conf.  :Wink: 

----------

## double_crane

 *Quote:*   

> Syslog-ng is very (very) (very) powerful, as you can read here. But it needs some time to understand how to properly configure it.
> 
> For exemple, to send all but your ACPI messages to /var/log/messages (didn't tested, you may have to tune the filter content) :
> 
> ```
> ...

 

thank you.

I see syslog-ng defines these by default

```

source src { system(); internal(); };

destination messages { file("/var/log/messages"); };

destination console_all { file("/dev/tty12"); };

log { source(src); destination(messages); };

log { source(src); destination(console_all); };

```

I comment " log { source(src); destination(messages); }; "

and system log won't be printed to /var/log/messages.

but there's no business with tty console ?

no matter I add syslog-ng filters or even stop syslog-ng service , the WARNINGs are still printed to tty character consoles.

are the WARNING messages  printed to consoles by kernel itself , not any other service or applications ? and so except changing kernel massage emergency level, there is no way to prevent its printing?

----------

## Syl20

Please post your whole syslog-ng.conf. There is certainly another rule explaining this behaviour.

----------

## double_crane

 *CneGroumF wrote:*   

> Please post your whole syslog-ng.conf. There is certainly another rule explaining this behaviour.

 

the default syslog-ng configuration file is as below

```

@version: 3.7

# $Id$

#

# Syslog-ng default configuration file for Gentoo Linux

# https://bugs.gentoo.org/show_bug.cgi?id=426814

@include "scl.conf"

options { 

   threaded(yes);

   chain_hostnames(no); 

   # The default action of syslog-ng is to log a STATS line

   # to the file every 10 minutes.  That's pretty ugly after a while.

   # Change it to every 12 hours so you get a nice daily update of

   # how many messages syslog-ng missed (0).

   stats_freq(43200); 

   # The default action of syslog-ng is to log a MARK line

   # to the file every 20 minutes.  That's seems high for most

   # people so turn it down to once an hour.  Set it to zero

   # if you don't want the functionality at all.

   mark_freq(3600); 

};

source src { system(); internal(); };

destination messages { file("/var/log/messages"); };

# By default messages are logged to tty12...

destination console_all { file("/dev/tty12"); };

# ...if you intend to use /dev/console for programs like xconsole

# you can comment out the destination line above that references /dev/tty12

# and uncomment the line below.

#destination console_all { file("/dev/console"); };

log { source(src); destination(messages); };

log { source(src); destination(console_all); };

```

default scl.conf

```

@define scl-root "`syslog-ng-data`/include/scl"

@define include-path "`include-path`:`syslog-ng-data`/include"

@include 'scl/*/*.conf'

```

I think the WARNING messages are printed by kernel by `printk`.

I do 

```
echo "4 4 1 7" >/proc/sys/kernel/printk
```

and then the WARNING messages disappear.

and do

```
echo "5 4 1 7" >/proc/sys/kernel/printk
```

the WARNING messages re-appear.

since the messages are printed to console by kernel, there's no way to stop it except adjust loglevel (or change kernel configure file), right ?

and syslog-ng service won't work beyond kernel limit, right?

thank you very much

----------

