473,385 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Logging from a .dll


I have a .exe that calls a .dll

I want to write log messages at various parts of the process in the .exe
and .dll to a common trace/log file.

I set up a method in the .exe to write to the trace file, but to append
basic information like DateTime.Now to each log entry.

How can I get my .dll to write to that same log file?

Feb 3 '06 #1
7 1479
The same way you did it in the EXE, just make sure to be referencing the
correct log assembly and namespace(s) in your DLL.

"John Bailo" <ja*****@texeme.com> wrote in message
news:b8********************@speakeasy.net...

I have a .exe that calls a .dll

I want to write log messages at various parts of the process in the .exe
and .dll to a common trace/log file.

I set up a method in the .exe to write to the trace file, but to append
basic information like DateTime.Now to each log entry.

How can I get my .dll to write to that same log file?

Feb 3 '06 #2
Peter Rilling wrote:
The same way you did it in the EXE, just make sure to be referencing the
correct log assembly and namespace(s) in your DLL.
What do you mean by "log assembly" ?

"John Bailo" <ja*****@texeme.com> wrote in message
news:b8********************@speakeasy.net...
I have a .exe that calls a .dll

I want to write log messages at various parts of the process in the .exe
and .dll to a common trace/log file.

I set up a method in the .exe to write to the trace file, but to append
basic information like DateTime.Now to each log entry.

How can I get my .dll to write to that same log file?


Feb 3 '06 #3
I mean the assembly the contains the log component. For example, whether it
be log4net, or System.Diagnostics, or something else. I was just being
generic and not assuming that you were using the framework classes for your
logging.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...
Peter Rilling wrote:
The same way you did it in the EXE, just make sure to be referencing the
correct log assembly and namespace(s) in your DLL.


What do you mean by "log assembly" ?

"John Bailo" <ja*****@texeme.com> wrote in message
news:b8********************@speakeasy.net...
I have a .exe that calls a .dll

I want to write log messages at various parts of the process in the .exe
and .dll to a common trace/log file.

I set up a method in the .exe to write to the trace file, but to append
basic information like DateTime.Now to each log entry.

How can I get my .dll to write to that same log file?



Feb 3 '06 #4

I see.

But my logging method (which just uses the Trace class) is in the .exe

So how would I write log entry from the .dll using a method in the .exe?

Peter Rilling wrote:
I mean the assembly the contains the log component. For example, whether it
be log4net, or System.Diagnostics, or something else. I was just being
generic and not assuming that you were using the framework classes for your
logging.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...
Peter Rilling wrote:
The same way you did it in the EXE, just make sure to be referencing the
correct log assembly and namespace(s) in your DLL.


What do you mean by "log assembly" ?

"John Bailo" <ja*****@texeme.com> wrote in message
news:b8********************@speakeasy.net...
I have a .exe that calls a .dll

I want to write log messages at various parts of the process in the .exe
and .dll to a common trace/log file.

I set up a method in the .exe to write to the trace file, but to append
basic information like DateTime.Now to each log entry.

How can I get my .dll to write to that same log file?

Feb 3 '06 #5
You cannot. You will have to move your logging code into a DLL for both the
EXE and DLL to be able to reference it.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...

I see.

But my logging method (which just uses the Trace class) is in the .exe

So how would I write log entry from the .dll using a method in the .exe?

Peter Rilling wrote:
I mean the assembly the contains the log component. For example, whether
it be log4net, or System.Diagnostics, or something else. I was just
being generic and not assuming that you were using the framework classes
for your logging.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...
Peter Rilling wrote:

The same way you did it in the EXE, just make sure to be referencing the
correct log assembly and namespace(s) in your DLL.

What do you mean by "log assembly" ?
"John Bailo" <ja*****@texeme.com> wrote in message
news:b8********************@speakeasy.net...
>I have a .exe that calls a .dll
>
>I want to write log messages at various parts of the process in the
>.exe and .dll to a common trace/log file.
>
>I set up a method in the .exe to write to the trace file, but to append
>basic information like DateTime.Now to each log entry.
>
>How can I get my .dll to write to that same log file?
>

Feb 4 '06 #6
Not quite true.

The only thing that has to be in the DLL is the interface. As long as the
EXE can create an object that derives from that interface, and can pass that
object to the classes defined in the DLL, then the classes in the DLL can
call the object to perform the logging.
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:eg*************@TK2MSFTNGP15.phx.gbl...
You cannot. You will have to move your logging code into a DLL for both
the EXE and DLL to be able to reference it.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...

I see.

But my logging method (which just uses the Trace class) is in the .exe

So how would I write log entry from the .dll using a method in the .exe?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Feb 4 '06 #7

Seems to me adding a logging Attribute in the metadata would solve the
problem.

Nick Malik [Microsoft] wrote:
Not quite true.

The only thing that has to be in the DLL is the interface. As long as the
EXE can create an object that derives from that interface, and can pass that
object to the classes defined in the DLL, then the classes in the DLL can
call the object to perform the logging.
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:eg*************@TK2MSFTNGP15.phx.gbl...
You cannot. You will have to move your logging code into a DLL for both
the EXE and DLL to be able to reference it.

"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...
I see.

But my logging method (which just uses the Trace class) is in the .exe

So how would I write log entry from the .dll using a method in the .exe?


Feb 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Karuppasamy | last post by:
H I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net I installed everything as per the Instructions given in the 'Development Using the Logging Block' ...
0
by: Karuppasamy | last post by:
Hi I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net . I installed everything as per the Instructions given in the 'Development Using the Logging Block'. ...
0
by: Karuppasamy | last post by:
H I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net I installed everything as per the Instructions given in the 'Development Using the Logging Block' ...
3
by: Karuppasamy | last post by:
Hi I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net . I installed everything as per the Instructions given in the 'Development Using the Logging Block'. ...
0
by: Karuppasamy | last post by:
Hi I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net . I installed everything as per the Instructions given in the 'Development Using the Logging Block'. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.