473,813 Members | 4,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

syslog function try to write to /dev folder

8 New Member
hello

In a perl script for a cronjob, there is a function:

Expand|Select|Wrap|Line Numbers
  1. sub _write_sys_log {
  2. my $seft = shift;
  3. my $level = shift;
  4. my $string = shift;
  5. syslog($level, '%s', "$string");
  6. }
This function is called from other function. I think that the function above should write logs to syslog file. However, it tries to write logs to /dev/consolog. As /dev/consolog is own by root, so it cannot write logs to this file. Therefore, it throws an error.

My question is how I can write these logs to syslog file. I am not good in perl and I am not the person who wrote this script, so please have some suggestions

Many thanks
Oct 10 '07 #1
7 2573
numberwhun
3,509 Recognized Expert Moderator Specialist
hello

In a perl script for a cronjob, there is a function:

Expand|Select|Wrap|Line Numbers
  1. sub _write_sys_log {
  2. my $seft = shift;
  3. my $level = shift;
  4. my $string = shift;
  5. syslog($level, '%s', "$string");
  6. }
This function is called from other function. I think that the function above should write logs to syslog file. However, it tries to write logs to /dev/consolog. As /dev/consolog is own by root, so it cannot write logs to this file. Therefore, it throws an error.

My question is how I can write these logs to syslog file. I am not good in perl and I am not the person who wrote this script, so please have some suggestions

Many thanks
I am going to take a guess here and say that in the script you are looking at, that they are using the Sys::Syslog module from CPAN. I say that because that is where I see the syslog() function defined.

That said, you should read that link as they probably have the open() function defined and pointing to the file it is trying to write to.

Also, I am guessing that you mean that this script is "run by the crontab". In that case, the reason they have this pointing to a root permission log is because when crontab jobs get run, it is the root user that is doing the executing.

Regards,

Jeff
Oct 10 '07 #2
johnhelen
8 New Member
Thank you, you right

I check and there is openlog call as:

openlog('NEW', '', 'local2);

Is it correct

Thanks
Oct 10 '07 #3
numberwhun
3,509 Recognized Expert Moderator Specialist
Thank you, you right

I check and there is openlog call as:

openlog('NEW', '', 'local2);

Is it correct

Thanks
You may want to read the functions part of the documentation. The first function is openlog() which it says has 3 parameters, where yours only has 2.

Unfortunately I haven't used this module and am unfamiliar with any caveats it may have, but it does look like that needs to be fixed.

Regards,

Jeff
Oct 10 '07 #4
johnhelen
8 New Member
Thanks for very quick reply
I also I discover that the "local2" facility (inside openlog function) is not in the /etc/syslog.conf file. Do you think that is the problem too ???


---------------------------------
You may want to read the functions part of the documentation. The first function is openlog() which it says has 3 parameters, where yours only has 2.

Unfortunately I haven't used this module and am unfamiliar with any caveats it may have, but it does look like that needs to be fixed.

Regards,

Jeff
Oct 10 '07 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
Thanks for very quick reply
I also I discover that the "local2" facility (inside openlog function) is not in the /etc/syslog.conf file. Do you think that is the problem too ???


---------------------------------
I would say that is the problem. I would track it down and see if the facility is modifiable.
Oct 10 '07 #6
johnhelen
8 New Member
"I would track it down and see if the facility is modifiable"

You mean that I should add one entry into the syslog.conf

local2.* /var/logs/syslog

So the log message will be written into syslog file ?

Many thanks for great help
Oct 10 '07 #7
numberwhun
3,509 Recognized Expert Moderator Specialist
"I would track it down and see if the facility is modifiable"

You mean that I should add one entry into the syslog.conf

local2.* /var/logs/syslog

So the log message will be written into syslog file ?

Many thanks for great help
Yes, that's exactly what I mean. Hope it works for you!

Regards,

Jeff
Oct 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2969
by: Erich Trowbridge | last post by:
Has anybody seen this tool? It is awesome. check out http://vw.vermeer.org/ . It's a php front end for large-scale syslog deployments. It makes managing syslog in large networks a snap. The idea is to fifo pipe network syslog into a MySQL database backend. The php scripts reference the database, and print stuff to the screen. My Info -> RH9.0 , MySQL 4.0.14, apache1.3.28 I have successfully gotten everything installed, compiled, etc....
5
3395
by: Micha³ Wo¼niak | last post by:
Hi again The Question of Logs, part II. :) What are the advantages/disadvantages of using syslog() to do the logging rather than writing the logs with fopen(), fwrite() and fclose()? What should be kept in mind while using either technique? And, of course, which is considered to be the better one? TIA
0
4631
by: Stephen Touset | last post by:
--=-vqiBeaRpc7WKjfgJmDzK Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Is there now a way within MySQL to log to syslog? I was reading an archived email conversation between Sinisa Milivojevic and Vincent Stoessel in which they seemed to indicate that there was no need to log to syslog. As Vincent only had a request for timestamps in the error log, Sinisa simply satisfied that demand and moved on. =20
1
3727
by: Gregory Starck | last post by:
Hello, I'm having what seems to be a deadlock in syslog with the code (wich comes from a project I'm working on, but I've reduced the test case to its minimum) I put at the end of this messsage. It must be compiled with -lpthread. (so the fork could be also a possible cause of what I'm mentionning). The "bug" does not occur every times. So you should maybe launch the prog a few times before the block occurs.
1
2531
by: liujixuan | last post by:
I am a new bie of Python. I knew there is module for syslog of Linux, but I want to create a syslog server on the windows server like windows 2k or 2k3, to collect the log message sent from our firewall. Any one has any idea about this? Many thanks. Jason Liu
1
1807
by: J Rice | last post by:
I have a question: When should syslog.closelog() be called? I have a daemon that spends most of its time asleep and quiet, but writes messages to the mail log when active. Should I open the log at the start and keep it open until the program closes? This seems much simpler than issuing three commands everytime I want to write to the log. The program will essentially be running constantly. Is having the log constantly "open" a...
3
6149
by: Troels Arvin | last post by:
Hello, On a server with DB2 v. 8.2, db2diag.log ran full, it seems (i.e. reached a size of 2GB). And it seems that in this case, DB2 started using syslog instead. I would actually like DB2 to use syslog instead of / in addition to the local log files, not only in case of a problem with the local log files. Is that possible?
1
2886
by: anjaliraman2 | last post by:
Hi All, I am facing a problem of writing into and reading from syslog in Linux Enviornment using C++. The CPU utilization is extremely high of about 55% and is creating problems for other processes. ideally the CPU utilization has to be only max of 10% not more. I have used getline() for reading. I hope u will please provide me a suitable solution. Thanks Anjali
1
6705
by: Lincoln Yeoh | last post by:
Hi, I've just started to learn python (I've been using perl for some years). How do I redirect ALL stderr stuff to syslog, even stderr from external programs that don't explicitly change their own stderr? Say I have a program called foo: #!/usr/bin/python
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10665
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10420
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.