Questions tagged [filehandler]

File handlers are mechanisms which provide abstraction over primitive file operations.

File handlers are modules (e.g. classes) which wrap primitive file operations (e.g. read, write) and file system operations (e.g. unlink, move, file watching) in helpful abstractions for specific usage scenarios.

For example, a file handler implemented as a class in opens a file in the format, reads each entry, and populates a list of row objects. In this case, the file handler has wrapped the open and read calls so the the caller need only know the name of the file.

Questions relating to the development of custom file handlers should include this tag. Additionally, questions which involve the use of standard or third-party file handlers may also include this tag.

See also:

147 questions
65
votes
3 answers

How to limit log file size in python

I am using windows 7 and python 2.7. I want to limit my log file size to 5MB. My app, when it starts, writes to log file, and then the app terminates. When my app starts again, it will write in same log file. So app is not continuously running. App…
imp
  • 1,967
  • 2
  • 28
  • 40
54
votes
2 answers

How do I get logger to delete existing log file before writing to it again?

Using the configuration below, my logfile will be called 'test-debug.log' and it will grow infinitely for everytime I run the script. I just want this logfile to contain the log records from the most recent run of the script. The log should be…
Paul H
  • 901
  • 2
  • 7
  • 12
33
votes
3 answers

Python logging: create log if not exists or open and continue logging if it does

I'm writing some code that uses the python logging system. The idea is that if the LOG doesn't already exist create the log but if it does then get the log and resume logging to that file. Here is my code: import logging import…
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
13
votes
4 answers

Change default location log file generated by logger in python

I am using logger in my python source code, and want to create logs on specific location but python logging module creates the log files at the default place i.e. from where it is executed. Is there is any way to change this default location? below…
Aman Jaiswal
  • 1,084
  • 2
  • 18
  • 36
12
votes
1 answer

Is java.util.logging.FileHandler in Java 8 broken?

First, a simple test code: package javaapplication23; import java.io.IOException; import java.util.logging.FileHandler; public class JavaApplication23 { public static void main(String[] args) throws IOException { new…
Remus
  • 123
  • 1
  • 7
10
votes
2 answers

Android: Open saved file in default app from my app

First off, sorry if this has been asked but I cannot find it. I am downloading documents in my app from a remote resource. Once the document is downloaded, I want to open it for the user. What I want to know is how do I check if they have an…
Tom Fobear
  • 6,729
  • 7
  • 42
  • 74
9
votes
1 answer

What happens if you don't close a filehandle in Perl?

If I am writing a Perl script that overwrites STDERR with a duplicate of STDOUT but I never restore the filehandle, what happens at the end of script execution? I can't find anything that warns against what actually occurs or doesn't occur. I'm…
0x1F602
  • 865
  • 5
  • 22
8
votes
5 answers

How to force a rotating name with python's TimedRotatingFileHandler?

I am trying to use TimedRotatingFileHandler to keep daily logs in separate log files. The rotation works perfectly as intended, but what I don't like how it does is the naming of the files. If I set a log file as my_log_file.log, this will be the…
Jester
  • 1,285
  • 14
  • 24
8
votes
3 answers

Dynamic generated image is requested twice when using jquery lazy loading in Google Chrome

I have an ashx file handler that generates my images. This all works fine. Now, I want to use lazy loading. Using this jquery lazy loading…
ThdK
  • 9,916
  • 23
  • 74
  • 101
6
votes
2 answers

How do I open a text file in Python?

Currently I am trying to open a text file called "temperature.txt" i have saved on my desktop using file handler, however for some reason i cannot get it to work. Could anyone tell me what im doing wrong. #!/Python34/python from math import * fh =…
Alex Osborne
  • 69
  • 1
  • 1
  • 2
5
votes
1 answer

Python proper logging with filehandlers

I am using python logging in my django application. A class that connects to a backend api initialises this logger with a filehandler if needed. The class gets instantiated everytime an api call is made. I have tried making sure additional handlers…
endre
  • 1,363
  • 1
  • 11
  • 22
5
votes
3 answers

java.io.IOException: Couldn't get lock for

Get error as "java.io.IOException: Couldn't get lock for ..\log\abc.log", not sure why this happen. Can somebody help me out? Thank you logger = LogManager.getLogManager().getLogger(className); FileHandler logFile = new…
Catheryan
  • 111
  • 1
  • 1
  • 8
4
votes
2 answers

Clickonce application and file handler behavior

I have a clickonce application, and I have set up several file handlers for this application (for the sake of this example, I want to handle files with either the .aaa or .bbb extensions). If I select a single file with one of these extensions, my…
slugster
  • 49,403
  • 14
  • 95
  • 145
4
votes
5 answers

Is Logging using FileHandler a bottleneck?

I am considering logging business events in a J2EE web application by using Java logging and FileHandler. I am wondering whether that could cause a performance bottleneck, since many log records will be written to one file. What are your…
TheLameProgrammer
  • 4,037
  • 5
  • 19
  • 16
4
votes
2 answers

Why doesn't TimedRotatingFileHandler work properly and how to solve this issue(rotation is working, but missing logging lines) when log lines

Update: TimedRotatingFileHandler is not working properly when I using multiprocessing, what am I supposed to do with multiprocessing logging? I wrote my own Logger class as below, use it as a module in all other python scripts. import logging import…
Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
1
2 3
9 10