# Can we make p4 program to log only specific variables

**URL:** <https://forum.p4.org/t/can-we-make-p4-program-to-log-only-specific-variables/110>\
**Category:** Education Working Group\
**Created:** [September 15, 2021, 1:42pm UTC](https://forum.p4.org/t/can-we-make-p4-program-to-log-only-specific-variables/110 "2021-09-15T13:42:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahrukh](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mahrukh](https://forum.p4.org/u/mahrukh)\
**Post date:** [September 15, 2021, 1:42pm UTC](https://forum.p4.org/t/can-we-make-p4-program-to-log-only-specific-variables/110/1 "2021-09-15T13:42:41Z")

</div>

Hi,  
I want to log field values from some headers using log\_msg.  
To enable it to work I used log console when starting the switch.  
This make a lot of not needed messages to be logged, increasing the size of logged file rapidly.  
It there a way to just log the fields that I have want to record using log\_msg.?

Thanks

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [September 15, 2021, 8:02pm UTC](https://forum.p4.org/t/can-we-make-p4-program-to-log-only-specific-variables/110/2 "2021-09-15T20:02:10Z")

</div>

This might not be the best answer to your question but if too many messages are generated and the file is too big, I used to open the log files with glogg (to prevent using editors that load the whole field in memory) and search the fields with it. That might be a partial-solution for your issue.

Cheers,
