<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run_with_log(self, dry_run=False, stage_files=True, resubmit_failed=False):
 """Runs this link with output sent to a pre-defined logfile Parameters dry_run : bool Print command but do not run it. stage_files : bool Copy files to and from scratch staging area. resubmit_failed : bool Flag for sub-classes to resubmit failed jobs. """

        fullkey = JobDetails.make_fullkey(self.full_linkname)
        job_details = self.jobs[fullkey]
        odir = os.path.dirname(job_details.logfile)
        try:
            os.makedirs(odir)
        except OSError:
            pass
        ostream = open(job_details.logfile, 'w')
        self.run(ostream, dry_run, stage_files, resubmit_failed)