Using an expression to set the log filename to include the date and time results in 3 log files being created.
Ummm. Why I only ran the package once. Is SSIS not sharing my log file connection among the different components
On first thought my workaround would involve using a script task to "set" the log file name to a variable and use an expression to set the log connection to the variable. But the problem with that is that logging starts BEFORE the script task is run...

Multiple Log Files
Tommy Upton
Hi Jason,
If you look at the 'Configure SSIS logs' window, you can see a check box against the package as well as against each task in it. So, if you have selected all, it will be executed for each one. Also there is a 'details' tab which is event specfic. So, if you have multiple events selected, then you will get multiple files.
Jason D_dot_NET
But that makes no sense Thiru.
If I configure a SINGLE log provider for the package I should get a SINGLE log file. It should make no difference to what components and details are checked or unchecked to how many files I get...
If the log filename is static (or at least using an expression which does not change during the execution of the package) then I get the expected SINGLE log file. But if the expression uses values which DO change during the execution (as in the current time), then I get multiple files.
And THAT makes no sense. At least from a design point of view. Most shops that do logging of executables/batch jobs/packages will either insert the date in the log filename (as in "MyLog_20060607.log") if the execution is once a day or use both the date and time in the log filename (as in "MyLog_20060607_162925.log") in ran multiple times a day. It SEEMS that SSIS cannot properly implement the second scenario.
Len Aye
SandyS48337
Hi,
It would be great if you can give more details about your package. Are you creating the log file in the 'OnPostExecute' of package or task Or is it in the 'OnError' section
If it is in the 'OnPostExecute' handler of package, then it will be executed after completion of each task in your package as well as at the end. If it is in the 'OnError' handler, then it will be executed for each error message. Note that even for a single error, SSIS will throw out 3-4 lines of error message and for each error message, your 'OnError' handler will be executed.
MiguelSilva
Nah, likely what is happening is the nature of when the logging is happening vs. where it is happening. Using time in the name means it will open the log everytime it doesn't find one with exactly the same name, which will be everytime it opens the log.
The log will get opened everytime the context of the execution (or validation) changes. If you're running this in the designer, logging happens during validation, execution, and post execution.
Now, think about where these three steps happen. Validation happens in the designer. Execution happens in the execution host, and then post execution logging happens back in the designer. I think.
Measure all this input with "Kirk's making a big guess!".
Log providers are only created once and open their destination media once per execution, not per container etc.
So, again, I think, without actually having a package to test this, this is a problem caused by the validation/execution context of the package.
To test the hypothesis, does it do the same thing when you execute the package in DTExec If so, the theory is full of holes and sinking to a miserable, cold death. If not, that's probably the problem. :)
K
Sathya E
I don't necessarily have an answer but a few suggestions to try:
These are more suggestions to work around the issue you are noticing rather than addressing it. Hope one of these helps.
m0gb0y74
Thiru,
I am not sure when the log file is being created. From the menu I selected SSIS --> Logging and create an xml logger from the dialog box.
I have two theories to what is happening.
1) Separate sections or levels are creating there own loggers (package level, control flow, and data flow -- 3 levels = 3 log files). Because they create them at slightly different times (varied by a second or two), the expression which uses the date and TIME in the filename returns 3 slightly different filenames, hence 3 different files.
2) The logger opens and closes the log file each time a log entry is written. Each time an entry is written the expression is used to get the filename and (same as above) because the date and TIME is used, potentially different filenames get returned. Is this is true (and I think this one is the culprit), I would expect to see more log files for longer running packages.
- Jason