Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > NAnt
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
NAnt For discussing the NAnt .NET build tool. When posting a question, please specify the version of NAnt you are using.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the NAnt section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 3rd, 2011, 08:47 AM
Registered User
Points: 14, Level: 1
Points: 14, Level: 1 Points: 14, Level: 1 Points: 14, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Nant Logger problem

Hi,
I need to create log file for my each build and for this I'm using command line as
nant -logfile:output.txt -buildfile:my.build -D:client.name=xyz-D:branch=abc

So above command is generating log file at same location at which my build script "my.build" is running (let say C:\build) and log file (output.txt) is Ok and contains all the required data

but I want to move Or copy each of generated log files to new location which will be created by variable are passed to script and for this I'm using below target to copy log to new directory


<target name="build">

<mkdir dir="${logger.dir}" if="${not directory::exists(logger.dir)}" />
<some command to compile solution>
----
<copy file="C:\build\output.txt" tofile="${logger.dir}\webbuild.${build.date}.txt" overwrite="true"/>

</target>

above target is copying empty webbuild.${build.date}.txt without any data.

I did some investigation and found that since nant is using output.txt in above commandline (i.e nant -logfile:output.txt -buildfile:my.build -D:client.name=xyz-D:branch=abc) so It's not allowing to me to copy Or move output file to new location.

Can anyone suggest me some solution for this ..As what approch I should follow to make this posible.

note : after my commandline completes then only I can copy the file..but i need to copy/move generated log file to new location at one go using same above commandline

Thanks,
Raju

Last edited by raju.sathliya; August 3rd, 2011 at 08:55 AM.
Reply With Quote
  #2 (permalink)  
Old August 3rd, 2011, 11:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You should use the <record> nant task instead. The logfile command line argument simply redirects the command line output to a log file. The record task lets you control what and how the build output is recorded. You can specify the file name using standard nant property syntax so it's variable. Usually, you'd start recording very early on outside of any targets so that it starts regardless of the called target. Then you use the built in "nant.onsuccess" and/or "nant.onfailure" properties to specify targets to run in each case. Use these targets to close the recording. I have a separate target to "finalize" the build log to minimize repetition.

Here are the relevant bits from a build file I use...

Code:
<project ... >

	<record name="${path.buildLog.file}" action="Start" />

	<property name="nant.onsuccess" value="onSuccess"/>
	<property name="nant.onfailure" value="onFailure" />

	<!-- other targets -->

	<target name="onSuccess">
		<echo message="Build Succeeded." />
		<call target="finalize" />
	</target>

	<target name="onFailure">
		<echo message="Build Failed." />
		<call target="finalize" />
	</target>

	<target name="finalize">
		<!-- other cleanup stuff here -->
		<record name="${path.buildLog.file}" action="Close" />
	</target>

</project>
__________________
-Peter
compiledthoughts.com
twitter/peterlanoie
Reply With Quote
The Following User Says Thank You to planoie For This Useful Post:
raju.sathliya (November 16th, 2011)
  #3 (permalink)  
Old November 16th, 2011, 11:15 AM
Registered User
Points: 14, Level: 1
Points: 14, Level: 1 Points: 14, Level: 1 Points: 14, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks Peter !! It's working fine now

Thanks Peter !! It's working fine now
Reply With Quote
  #4 (permalink)  
Old May 1st, 2015, 04:57 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I need to log error reason message on failure. I do not want entire log details and just want to log error message to different log file.
Will Record task help?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
NAnt - External Program Failed mercurysmiles NAnt 1 November 20th, 2008 10:40 AM
how to connect to remote machine using nant kalpana2009 NAnt 0 October 8th, 2007 08:25 AM
Building web application using NANT ydevesh NAnt 0 November 17th, 2006 09:30 AM
Logger.getInstance in Action Class ramanadyv Struts 1 January 16th, 2006 05:44 AM
ViewState Size Logger mohandeval Classic ASP Basics 0 August 16th, 2005 03:58 PM



All times are GMT -4. The time now is 03:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.