473,586 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable console display while enabling logging to a file.

1 New Member
I have the following code in a module that I want to call from any other application module.
The code I have also displays the debug message on the console when I invoke it like this:
def main():
logger = custom_logger(' test1', 'log', 'test.log', False)
logger.debug('l og to file only')

Not sure how to turn off the console.
Any thoughts?
Thanks.

custom_logger(l ogdir, logfile, logname, logconsole)
logger = logging.getLogg er(logname)

formatter = logging.Formatt er(fmt='%(ascti me)s [%(name)-2s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')

rotatingfilehan dler = RotatingFileHan dler(logdir+'/'+logfile,
maxBytes=MAX_LO GSIZE,
backupCount=MAX _ROTATE_LOGS)
rotatingfilehan dler.setFormatt er(formatter)
logger.addHandl er(rotatingfile handler)

screen_handler = logging.StreamH andler(stream=s ys.stdout)
screen_handler. setFormatter(fo rmatter)

if logconsole:
logger.addHandl er(screen_handl er)
else:
logger.removeHa ndler(screen_ha ndler)

return logger
Aug 7 '19 #1
0 1127

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

Similar topics

5
2490
by: Victor | last post by:
Hi I need to open an html file from the file system and embed that html file within my main aspx form. I have 2 questions: 1) How do I open the html file? I tried the File.open(Path, mode) didnt work. 2) I would like to display the html file at a certain location in my main aspx page. How can I achieve this? I'm brain dead and I have to...
3
3884
by: jiayanxiang | last post by:
Is there any sample code to use Javascript to load and display a text file? It will be best if the user can select files using some kind of explorer. If that's complex, a text box to specify the file name will be fine as well. Once a text file is selected, I just need to display it in a text box. Thanks for the help.
3
2966
by: Chris Saunders | last post by:
May be a dumb question but I have been unable to find the answer on my own. I wish to display a help file (*.chm) can anyone help? I attempted using "displaying help file" as a search in MSDN but no found articles seemed to have what I wanted. Regards Chris Saunders
3
2004
by: johnny | last post by:
How do I pipe the output, generated from os.system(some_command), to the logging file?
11
3180
by: nickyeng | last post by:
I have a html file contains a form asking user to select a choice and press enter to pass the data to server. In server there, i have a cgi script(C language) that accepts the input from browser and then output a html page to browser. The browser should open the page, but it didn't, instead, it prompt me to save the file(.cgi file i...
1
4567
by: 848lu | last post by:
PHP - display from txt file with explode function hi, i am trying to display all data from a txt file with a function of explode but does not work..... <? #reads a text file outputs it to screen $filename = "cdlist.txt"; $filepointer = fopen($filename,"r"); // open for read $cdArray = file ($filename);
9
2068
by: tomhawkins1 | last post by:
Hi I currently have a site where users can upload files. These files can be doc, wmv, jpeg, xls, dwf, dwf and dwg. These files are uploaded to /home/**user**/uploads and not /home/ **user**/public_html/uploads to prevent any old user from browsing them. I then use a general showDoc page with the following function (from
3
2837
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net app, in the page there is a scan activex which could scan and save a jpg file in client harddisk. How could we access and display this jpg file on the fly using js in the client IE? Thanks, -Billy zhang
4
5469
by: kkshansid | last post by:
what is the best way to display a word file on a php page in the same format as it is on word format ? word file has some very well diplay of data in tabular format php page has includes header,footer,left,right i want to display it in the middle but by simply copy pasting error it doesnt display in the same format
2
1603
by: harika143 | last post by:
in console loggers are not printing. can any body tell me the reason. i set the classpath for log4j.jar are log4j.xml. but i am not getting.
0
7841
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...
0
8204
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. ...
0
8220
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...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
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...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
0
1184
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...

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.