# logging errors using perl

**URL:** <https://community.unix.com/t/logging-errors-using-perl/286106>\
**Category:** Shell Programming and Scripting\
**Created:** [April 10, 2011, 9:41pm UTC](https://community.unix.com/t/logging-errors-using-perl/286106 "2011-04-10T21:41:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anjan1](https://community.unix.com/letter_avatar/anjan1/32/6_449c533f586939b6e5f246632a46421f.png) [@Anjan1](https://community.unix.com/u/Anjan1)\
**Post date:** [April 10, 2011, 9:41pm UTC](https://community.unix.com/t/logging-errors-using-perl/286106/1 "2011-04-10T21:41:03Z")

</div>

Hi,

Can some one please tell me how to redirect only errors to the log file using perl.

Thanks,  
Anjan.

---------- Post updated at 08:41 PM ---------- Previous update was at 08:39 PM ----------

Also, i dont want to use any module. Please tell me in normal way

---

<div class="post-metadata">

**Author:** ![pravin27](https://community.unix.com/letter_avatar/pravin27/32/6_449c533f586939b6e5f246632a46421f.png) [@pravin27](https://community.unix.com/u/pravin27)\
**Post date:** [April 11, 2011, 1:15am UTC](https://community.unix.com/t/logging-errors-using-perl/286106/2 "2011-04-11T01:15:22Z")

</div>

You can capture all the error using below code. It will log all the error in the file test,txt.

```nohighlight
open STDERR, ">test.txt" or die "Can't open file for STDERR";

```
